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
Showing
1 changed file
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
'use strict'; | ||
|
||
const proxyquire = require('proxyquire'); | ||
const fakeArgv = { 'skip-bar': true }; | ||
const skip = proxyquire('../../../lib/plugins/groupTasks/skip', { | ||
'../../argv': fakeArgv, | ||
}); | ||
const STATE_SKIP = false; | ||
const STATE_DO_NOT_SKIP = true; | ||
|
||
describe('skipFactory', () => { | ||
it('returns a skip function', () => { | ||
expect(typeof skip('foo')).toBe('function'); | ||
}); | ||
}); | ||
|
||
describe('skip', () => { | ||
it('does not skip non-matching tasks', () => { | ||
const task = { | ||
displayName: 'bar:foo', | ||
}; | ||
|
||
expect(skip('bar')(task)).toBe(STATE_DO_NOT_SKIP); | ||
}); | ||
|
||
it('does not skip tasks with non-matching subcategory', () => { | ||
const task = { | ||
displayName: 'foo:lorem:bar', | ||
}; | ||
|
||
expect(skip('foo')(task)).toBe(STATE_DO_NOT_SKIP); | ||
}); | ||
|
||
it('does not skip tasks with non-matching basename', () => { | ||
const task = { | ||
displayName: 'foo:bar', | ||
}; | ||
|
||
expect(skip('lorem')(task)).toBe(STATE_DO_NOT_SKIP); | ||
}); | ||
|
||
it('does not skip non-matching tasks of subcategory', () => { | ||
fakeArgv['skip-foo:lorem'] = true; | ||
|
||
const task = { | ||
displayName: 'foo:foo:ipsum', | ||
}; | ||
|
||
expect(skip('foo')(task)).toBe(STATE_DO_NOT_SKIP); | ||
}); | ||
|
||
it('skips matching tasks', () => { | ||
const task = { | ||
displayName: 'foo:bar', | ||
}; | ||
|
||
expect(skip('foo')(task)).toBe(STATE_SKIP); | ||
}); | ||
|
||
it('skips tasks matching by subcategory', () => { | ||
const task = { | ||
displayName: 'foo:bar:lorem', | ||
}; | ||
|
||
expect(skip('foo')(task)).toBe(STATE_SKIP); | ||
}); | ||
|
||
it('skips tasks matching by subcategory and taskname', () => { | ||
fakeArgv['skip-foo:lorem'] = true; | ||
|
||
const task = { | ||
displayName: 'foo:foo:lorem', | ||
}; | ||
|
||
expect(skip('foo')(task)).toBe(STATE_SKIP); | ||
}); | ||
}); |