Skip to content

Commit

Permalink
Tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
drag13 committed Feb 6, 2018
1 parent 55977fc commit fab0b9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

'use strict';

const trueActionIsNotAFunctionError = 'Expected function but got ';

/**
* compose predicate and if else functions to the new function
* @param {(function|boolean)} predicate - function or anything else that can be treated as bool.
Expand Down
22 changes: 9 additions & 13 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ describe('whenDo function', () => {
});

it('should return function', () => {
expect(whendo()).to.be.an('function');
expect(whendo(true, function () { })).to.be.an('function');
});
});

describe('if predicate', () => {
const spy = chai.spy;
const spy = chai.spy, context = {};
let trueAction, falseAction;

beforeEach(() => {
Expand All @@ -39,9 +39,8 @@ describe('if predicate', () => {
expect(trueAction).to.have.been.called.with('test');
});

it('is not a function, nothing should fail', () => {
const ifthen = whendo(true, null, falseAction);
expect(ifthen()).expect.to.throw(new Error(`const trueActionIsNotAFunctionError = ${typeof undefined}`));
it('is not a function, exception should be thrown', () => {
expect(whendo.bind(context, true, true, falseAction)).to.throw();
});
});
});
Expand All @@ -59,8 +58,7 @@ describe('if predicate', () => {
});

it('is not a function, nothing should fail', () => {
const ifthen = whendo(false, trueAction, null)();
expect(true).to.be.true;
expect(whendo.bind(context, false, trueAction, null)).not.to.throw();
});
});
});
Expand All @@ -78,9 +76,8 @@ describe('if predicate', () => {
expect(trueAction).to.have.been.called.with('test');
});

it('is not a function, nothing should fail', () => {
const ifthen = whendo(fpredicate, null, falseAction)();
expect(true).to.be.true;
it('is not a function, exception should be thrown', () => {
expect(whendo.bind(context, true, true, falseAction)).to.throw();
});
});
});
Expand All @@ -98,9 +95,8 @@ describe('if predicate', () => {
expect(falseAction).to.have.been.called.with('test');
});

it('is not a function, nothing should fail', () => {
const ifthen = whendo(fpredicate, trueAction, null)();
expect(true).to.be.true;
it('is not a function, nothing should fails', () => {
expect(whendo.bind(context, false, trueAction, null)).not.to.throw();
});
});
});
Expand Down

0 comments on commit fab0b9e

Please sign in to comment.