2017-05-31 23:39:08 -05:00
|
|
|
const getCmdLineArg = require('../../js/utils/getCmdLineArg.js');
|
|
|
|
|
|
|
|
describe('getCmdLineArg tests', function() {
|
|
|
|
it('should return no exact match', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const result = getCmdLineArg(['hello.exe', '--arg1', '--arg2'], '--arg', true);
|
2017-05-31 23:39:08 -05:00
|
|
|
expect(result).toBe(null);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return exact match only', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const result = getCmdLineArg(['hello.exe', '--arg1', '--arg2'], '--arg2', true);
|
2017-05-31 23:39:08 -05:00
|
|
|
expect(result).toBe('--arg2');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return starts with match', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const result = getCmdLineArg(['hello.exe', '--hello=test', '--arg2'], '--hello=', false);
|
2017-05-31 23:39:08 -05:00
|
|
|
expect(result).toBe('--hello=test');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return no match for starts with', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const result = getCmdLineArg(['hello.exe', '--hello=test', '--arg2'], '--help=', false);
|
2017-05-31 23:39:08 -05:00
|
|
|
expect(result).toBe(null);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return no match invalid argv given', function() {
|
2017-08-24 02:51:02 -05:00
|
|
|
const result = getCmdLineArg('invalid argv', '--help=', false);
|
2017-05-31 23:39:08 -05:00
|
|
|
expect(result).toBe(null);
|
|
|
|
});
|
|
|
|
});
|