|
|
@ -59,32 +59,31 @@ t.describe('CLI', function() {
|
|
|
|
*****************************************/
|
|
|
|
*****************************************/
|
|
|
|
|
|
|
|
|
|
|
|
t.describe('#parseOptions()', function() {
|
|
|
|
t.describe('#parseOptions()', function() {
|
|
|
|
|
|
|
|
t.beforeEach(function() {
|
|
|
|
|
|
|
|
cli.loadDefaults()
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should not do anything if no options', async function() {
|
|
|
|
t.test('should not do anything if no options', async function() {
|
|
|
|
cli.reporter = 'list'
|
|
|
|
|
|
|
|
await cli.parseOptions([])
|
|
|
|
await cli.parseOptions([])
|
|
|
|
assert.strictEqual(cli.reporter, 'list')
|
|
|
|
assert.strictEqual(cli.reporter, 'list')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding reporter with shorthand option', async function() {
|
|
|
|
t.test('should support overriding reporter with shorthand option', async function() {
|
|
|
|
cli.reporter = 'list'
|
|
|
|
|
|
|
|
await cli.parseOptions(['-r', 'dot'])
|
|
|
|
await cli.parseOptions(['-r', 'dot'])
|
|
|
|
assert.strictEqual(cli.reporter, 'dot')
|
|
|
|
assert.strictEqual(cli.reporter, 'dot')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding reporter with long option', async function() {
|
|
|
|
t.test('should support overriding reporter with long option', async function() {
|
|
|
|
cli.reporter = 'list'
|
|
|
|
|
|
|
|
await cli.parseOptions(['--reporter', 'dot'])
|
|
|
|
await cli.parseOptions(['--reporter', 'dot'])
|
|
|
|
assert.strictEqual(cli.reporter, 'dot')
|
|
|
|
assert.strictEqual(cli.reporter, 'dot')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support enabling ignore-only long option', async function() {
|
|
|
|
t.test('should support enabling ignore-only long option', async function() {
|
|
|
|
cli.ignoreOnly = false
|
|
|
|
|
|
|
|
await cli.parseOptions(['--ignore-only', '-r', 'dot'])
|
|
|
|
await cli.parseOptions(['--ignore-only', '-r', 'dot'])
|
|
|
|
assert.strictEqual(cli.ignoreOnly, true)
|
|
|
|
assert.strictEqual(cli.ignoreOnly, true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support reporter list', async function() {
|
|
|
|
t.test('should support reporter list', async function() {
|
|
|
|
cli.reporter = 'list'
|
|
|
|
|
|
|
|
await cli.parseOptions(['-r', 'list'])
|
|
|
|
await cli.parseOptions(['-r', 'list'])
|
|
|
|
assert.strictEqual(cli.reporter, 'list')
|
|
|
|
assert.strictEqual(cli.reporter, 'list')
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -100,13 +99,11 @@ t.describe('CLI', function() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding timeout with shorthand option', async function() {
|
|
|
|
t.test('should support overriding timeout with shorthand option', async function() {
|
|
|
|
cli.timeout = 2000
|
|
|
|
|
|
|
|
await cli.parseOptions(['-t', '1000'])
|
|
|
|
await cli.parseOptions(['-t', '1000'])
|
|
|
|
assert.strictEqual(cli.timeout, 1000)
|
|
|
|
assert.strictEqual(cli.timeout, 1000)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding timeout with long option', async function() {
|
|
|
|
t.test('should support overriding timeout with long option', async function() {
|
|
|
|
cli.timeout = 2000
|
|
|
|
|
|
|
|
await cli.parseOptions(['--timeout', '250'])
|
|
|
|
await cli.parseOptions(['--timeout', '250'])
|
|
|
|
assert.strictEqual(cli.timeout, 250)
|
|
|
|
assert.strictEqual(cli.timeout, 250)
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -122,57 +119,54 @@ t.describe('CLI', function() {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding watch', async function() {
|
|
|
|
t.test('should support overriding watch', async function() {
|
|
|
|
cli.watch = null
|
|
|
|
|
|
|
|
await cli.parseOptions(['-w', 'unittest_test1'])
|
|
|
|
await cli.parseOptions(['-w', 'unittest_test1'])
|
|
|
|
assert.strictEqual(cli.watch, 'unittest_test1')
|
|
|
|
assert.strictEqual(cli.watch, 'unittest_test1')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding watch with long option', async function() {
|
|
|
|
t.test('should support overriding watch with long option', async function() {
|
|
|
|
cli.watch = null
|
|
|
|
|
|
|
|
await cli.parseOptions(['--watch', 'unittest_test1'])
|
|
|
|
await cli.parseOptions(['--watch', 'unittest_test1'])
|
|
|
|
assert.strictEqual(cli.watch, 'unittest_test1')
|
|
|
|
assert.strictEqual(cli.watch, 'unittest_test1')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should fail overriding if next parameter is missing', async function() {
|
|
|
|
t.test('should fail setting watch if value is missing', async function() {
|
|
|
|
cli.watch = null
|
|
|
|
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['--watch']))
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['--watch']))
|
|
|
|
assert.strictEqual(cli.watch, null)
|
|
|
|
assert.strictEqual(cli.watch, null)
|
|
|
|
assert.match(err.message, /watch/i)
|
|
|
|
assert.match(err.message, /watch/i)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should fail overriding if next parameter is a parameter', async function() {
|
|
|
|
t.test('should fail setting watch if value is parameter', async function() {
|
|
|
|
cli.watch = null
|
|
|
|
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['-w', '--reporter', 'list']))
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['-w', '--reporter', 'list']))
|
|
|
|
assert.strictEqual(cli.watch, null)
|
|
|
|
assert.strictEqual(cli.watch, null)
|
|
|
|
assert.match(err.message, /watch/i)
|
|
|
|
assert.match(err.message, /watch/i)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding run', async function() {
|
|
|
|
t.test('should support overriding run', async function() {
|
|
|
|
cli.run = null
|
|
|
|
|
|
|
|
await cli.parseOptions(['-n', 'unittest_run1'])
|
|
|
|
await cli.parseOptions(['-n', 'unittest_run1'])
|
|
|
|
assert.strictEqual(cli.run, 'unittest_run1')
|
|
|
|
assert.strictEqual(cli.run, 'unittest_run1')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should support overriding run with long option', async function() {
|
|
|
|
t.test('should support overriding run with long option', async function() {
|
|
|
|
cli.run = null
|
|
|
|
|
|
|
|
await cli.parseOptions(['--npm', 'unittest_run1'])
|
|
|
|
await cli.parseOptions(['--npm', 'unittest_run1'])
|
|
|
|
assert.strictEqual(cli.run, 'unittest_run1')
|
|
|
|
assert.strictEqual(cli.run, 'unittest_run1')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should fail overriding if next parameter is missing', async function() {
|
|
|
|
t.test('should fail setting npm if value is missing', async function() {
|
|
|
|
cli.run = null
|
|
|
|
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['--npm']))
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['--npm']))
|
|
|
|
assert.strictEqual(cli.run, null)
|
|
|
|
assert.strictEqual(cli.run, 'test')
|
|
|
|
assert.match(err.message, /npm/i)
|
|
|
|
assert.match(err.message, /npm/i)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should fail overriding if next parameter is a parameter', async function() {
|
|
|
|
t.test('should fail setting npm if value is parameter', async function() {
|
|
|
|
cli.run = null
|
|
|
|
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['-n', '--reporter', 'list']))
|
|
|
|
let err = await assert.isRejected(cli.parseOptions(['-n', '--reporter', 'list']))
|
|
|
|
assert.strictEqual(cli.run, null)
|
|
|
|
assert.strictEqual(cli.run, 'test')
|
|
|
|
assert.match(err.message, /npm/i)
|
|
|
|
assert.match(err.message, /npm/i)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.test('when using run and no target, leave target empty', async function() {
|
|
|
|
|
|
|
|
await cli.parseOptions(['--npm', 'unittest_run1'])
|
|
|
|
|
|
|
|
assert.strictEqual(cli.targets.length, 0)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('should add file to targets', async function() {
|
|
|
|
t.test('should add file to targets', async function() {
|
|
|
|
await cli.parseOptions(['test'])
|
|
|
|
await cli.parseOptions(['test'])
|
|
|
|
assert.deepEqual(cli.targets, ['test'])
|
|
|
|
assert.deepEqual(cli.targets, ['test'])
|
|
|
@ -756,10 +750,10 @@ t.describe('CLI', function() {
|
|
|
|
|
|
|
|
|
|
|
|
assert.ok(eltro.starting)
|
|
|
|
assert.ok(eltro.starting)
|
|
|
|
assert.strictEqual(loaded.length, 2)
|
|
|
|
assert.strictEqual(loaded.length, 2)
|
|
|
|
assert.match(loaded[0], path.join('root', testFiles[1]))
|
|
|
|
assert.match(loaded[0], new RegExp(path.join('root', testFiles[1]).replace(/\\/g, '\\\\')))
|
|
|
|
assert.match(loaded[1], path.join('root', testFiles[2]))
|
|
|
|
assert.match(loaded[1], new RegExp(path.join('root', testFiles[2]).replace(/\\/g, '\\\\')))
|
|
|
|
assert.match(filenames[0], testFiles[1])
|
|
|
|
assert.match(filenames[0], new RegExp(testFiles[1].replace(/\\/g, '\\\\')))
|
|
|
|
assert.match(filenames[1], testFiles[2])
|
|
|
|
assert.match(filenames[1], new RegExp(testFiles[2].replace(/\\/g, '\\\\')))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
t.test('on error should throw and wrap in inner error', async function() {
|
|
|
|
t.test('on error should throw and wrap in inner error', async function() {
|
|
|
|