Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b47016
commit f9db00b
Showing
2 changed files
with
56 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict' | ||
|
||
const test = require('tape') | ||
const cli = require('../cli') | ||
|
||
test('allow a string to be ignored', (assert) => { | ||
assert.plan(1) | ||
cli.filter('foo.js') | ||
assert.deepEqual(cli.ignorePattern, ['foo.js']) | ||
cli._initiate() | ||
}) | ||
|
||
test('allow an array of globs to be ignored', (assert) => { | ||
assert.plan(1) | ||
cli.filter(['foo.js', 'bar.js']) | ||
assert.deepEqual(cli.ignorePattern, ['foo.js', 'bar.js']) | ||
cli._initiate() | ||
}) | ||
|
||
test('allow a callback to be passed to filter fn', (assert) => { | ||
assert.plan(2) | ||
cli.filter(function () {}) | ||
assert.equal(typeof (cli.filterCallback), 'function') | ||
assert.equal(cli.ignorePattern.length, 0) | ||
cli._initiate() | ||
}) | ||
|
||
test('throw exception when filter param is not an array,string of fn', (assert) => { | ||
assert.plan(1) | ||
try { | ||
cli.filter({}) | ||
} catch (error) { | ||
assert.equal(error.message, 'cli.filter only excepts a glob string, array or a callback function') | ||
cli._initiate() | ||
} | ||
}) | ||
|
||
test('set glob pattern for test files', (assert) => { | ||
assert.plan(2) | ||
assert.equal(cli.testsGlob, 'test/*.spec.js') | ||
cli.run('test/**/*.js') | ||
assert.equal(cli.testsGlob, 'test/**/*.js') | ||
cli._initiate() | ||
}) | ||
|
||
test('throw exception when pattern is not a string', (assert) => { | ||
assert.plan(1) | ||
try { | ||
cli.run(['test/**/*.js']) | ||
} catch (error) { | ||
assert.equal(error.message, 'cli.run excepts glob pattern to be a string. You passed object') | ||
cli._initiate() | ||
} | ||
}) |