Skip to content

Commit

Permalink
test(groupTasks): add tests for PluginGroupTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiphe committed Mar 5, 2016
1 parent 283f3dd commit 13e9e69
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions test/plugins/groupTasks/PluginGroupTasksSpec.js
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);
});
});
});

0 comments on commit 13e9e69

Please sign in to comment.