You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1020 B

import { parse_args } from '../src/logic';
const process = require('process');
const process_mock = jest.spyOn(process, 'exit').mockImplementation(() => true);
describe('test parse args', () => {
it('parses a single page id with -p', () => {
const res = parse_args(['-p', 'foo']);
expect(res).toEqual({ page_ids: ['https://www.facebook.com/foo/events/'] });
});
it('parses a single page id with --page', () => {
const res = parse_args(['--page=foo']);
expect(res).toEqual({ page_ids: ['https://www.facebook.com/foo/events/'] });
});
it('parses multiple page ids with --pages', () => {
const res = parse_args(['--pages=foo,bar']);
expect(res).toEqual({
page_ids: [
'https://www.facebook.com/foo/events/',
'https://www.facebook.com/bar/events/',
],
});
});
['-?', '--help', '-h'].forEach((param) => {
it('parses help options', () => {
const res = parse_args([param]);
expect(process_mock).toHaveBeenCalledWith(1);
});
});
});