-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(groupTasks): add tests for PluginGroupTasks
- Loading branch information
Showing
1 changed file
with
70 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,70 @@ | ||
'use strict'; | ||
|
||
const proxyquire = require('proxyquire'); | ||
|
||
describe('PluginGroupTasks', () => { | ||
let pluginGroupTasks = null; | ||
let fakeStartsWith = null; | ||
let fakeSkip = null; | ||
let fakeGroup = null; | ||
|
||
beforeEach(() => { | ||
fakeStartsWith = jasmine.createSpy('startsWith'); | ||
fakeSkip = jasmine.createSpy('skip'); | ||
fakeGroup = jasmine.createSpy('group'); | ||
|
||
const PluginGroupTasks = proxyquire( | ||
'../../../lib/plugins/groupTasks/PluginGroupTasks', | ||
{ | ||
'./startsWith': () => fakeStartsWith, | ||
'./skip': () => fakeSkip, | ||
'./group': () => fakeGroup, | ||
} | ||
); | ||
|
||
pluginGroupTasks = new PluginGroupTasks(); | ||
}); | ||
|
||
describe('init', () => { | ||
it('puts a given store aside for later usage', () => { | ||
const someStore = Symbol(); | ||
|
||
pluginGroupTasks.init(someStore); | ||
|
||
expect(pluginGroupTasks.store).toBe(someStore); | ||
}); | ||
}); | ||
|
||
describe('get', () => { | ||
it('does nothing if a task was found', () => { | ||
const args = { task: true }; | ||
Object.freeze(args); | ||
|
||
expect(pluginGroupTasks.get(args)).toBe(args); | ||
}); | ||
|
||
it('builds a grouped task from store', () => { | ||
const aTask = Symbol(); | ||
const store = { | ||
tasks: [aTask], | ||
}; | ||
const name = 'fuchs'; | ||
const args = { name }; | ||
const theGroup = Symbol(); | ||
|
||
Object.freeze(args); | ||
pluginGroupTasks.store = store; | ||
fakeStartsWith.and.returnValue(true); | ||
fakeSkip.and.returnValue(true); | ||
fakeGroup.and.returnValue(theGroup); | ||
|
||
const newArgs = pluginGroupTasks.get(args); | ||
const at = jasmine.anything(); | ||
|
||
expect(newArgs.task).toBe(theGroup); | ||
expect(newArgs.name).toBe(name); | ||
expect(fakeStartsWith).toHaveBeenCalledWith(aTask, at, at); | ||
expect(fakeSkip).toHaveBeenCalledWith(aTask, at, at); | ||
}); | ||
}); | ||
}); |