pulsar/spec/main-process/parse-command-line.test.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-05-31 19:33:56 +03:00
const { assert } = require('chai');
const parseCommandLine = require('../../src/main-process/parse-command-line');
describe('parseCommandLine', () => {
describe('when --uri-handler is not passed', () => {
it('parses arguments as normal', () => {
2019-02-22 10:55:17 +03:00
const args = parseCommandLine([
'-d',
'--safe',
'--test',
'/some/path',
'atom://test/url',
'atom://other/url'
2019-05-31 19:33:56 +03:00
]);
assert.isTrue(args.devMode);
assert.isTrue(args.safeMode);
assert.isTrue(args.test);
assert.deepEqual(args.urlsToOpen, [
'atom://test/url',
'atom://other/url'
]);
assert.deepEqual(args.pathsToOpen, ['/some/path']);
});
});
describe('when --uri-handler is passed', () => {
it('ignores other arguments and limits to one URL', () => {
2019-02-22 10:55:17 +03:00
const args = parseCommandLine([
'-d',
'--uri-handler',
'--safe',
'--test',
'/some/path',
'atom://test/url',
'atom://other/url'
2019-05-31 19:33:56 +03:00
]);
assert.isUndefined(args.devMode);
assert.isUndefined(args.safeMode);
assert.isUndefined(args.test);
assert.deepEqual(args.urlsToOpen, ['atom://test/url']);
assert.deepEqual(args.pathsToOpen, []);
});
});
});