Skip to content

Commit

Permalink
added test for issue 23.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummy committed Mar 6, 2019
1 parent 39bfc7d commit 9fccf08
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/spec/issues/18.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/spec/issues/23.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
14 changes: 14 additions & 0 deletions dist/spec/issues/23.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/spec/issues/23.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/issues/18.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface CalculatorInterface {
}

test('issue 18: receive with arg', t => {
const mockedCalculator = Substitute.for<CalculatorInterface>()
const mockedCalculator = Substitute.for<CalculatorInterface>();
mockedCalculator.add(1, Arg.is(input => input === 2)).returns(4);

void mockedCalculator.add(1, 2);
Expand Down
23 changes: 23 additions & 0 deletions spec/issues/23.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import test from 'ava';

import { Substitute, Arg } from '../../src/Index';

interface CalculatorInterface {
add(a: number, b: number): number
subtract(a: number, b: number): number
divide(a: number, b: number): number
isEnabled: boolean
}

test('issue 23: mimick received should not call method', t => {
const mockedCalculator = Substitute.for<CalculatorInterface>();

let result = 0;
mockedCalculator.add(Arg.all()).mimicks((a, b) => {
return result = a + b;
});

t.throws(() => mockedCalculator.received().add(Arg.any(), Arg.any()));

t.is(result, 0);
});

0 comments on commit 9fccf08

Please sign in to comment.