Skip to content

Commit

Permalink
Add return functionality with test; (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
RGBboy authored and ryym committed Apr 25, 2017
1 parent e9bfd29 commit f9fb01a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function makeTestBody(param, test, isAsync) {
};
}
return function() {
test.apply(this, param);
return test.apply(this, param);
};
}

Expand Down
12 changes: 11 additions & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ describe('mocha-each', () => {
assert.equal(test.thisValues[0], _this);
});

it('returns the return value of the test function', () => {
const expected = 'test';
const test = () => { return expected; };
const _it = (name, b) => body = b;
let body;
forEach([0], _it).it('', test);
const returnValue = body.call(null);
assert.equal(returnValue, expected);
});

context('without Mocha', () => {
it('throws an error when called', () => {
delete global.it;
Expand Down Expand Up @@ -156,6 +166,7 @@ describe('mocha-each', () => {
body.call(expectedThis, () => {});
assert.equal(actualThis, expectedThis);
});

});

context('when the lengths of parameters are different', () => {
Expand Down Expand Up @@ -274,4 +285,3 @@ describe('mocha-each', () => {
});
});
});

0 comments on commit f9fb01a

Please sign in to comment.