Skip to content

Commit 9fccf08

Browse files
author
Dummy
committed
added test for issue 23.
1 parent 39bfc7d commit 9fccf08

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

dist/spec/issues/18.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spec/issues/23.test.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

dist/spec/issues/23.test.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spec/issues/23.test.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/issues/18.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface CalculatorInterface {
1010
}
1111

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

1616
void mockedCalculator.add(1, 2);

spec/issues/23.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import test from 'ava';
2+
3+
import { Substitute, Arg } from '../../src/Index';
4+
5+
interface CalculatorInterface {
6+
add(a: number, b: number): number
7+
subtract(a: number, b: number): number
8+
divide(a: number, b: number): number
9+
isEnabled: boolean
10+
}
11+
12+
test('issue 23: mimick received should not call method', t => {
13+
const mockedCalculator = Substitute.for<CalculatorInterface>();
14+
15+
let result = 0;
16+
mockedCalculator.add(Arg.all()).mimicks((a, b) => {
17+
return result = a + b;
18+
});
19+
20+
t.throws(() => mockedCalculator.received().add(Arg.any(), Arg.any()));
21+
22+
t.is(result, 0);
23+
});

0 commit comments

Comments
 (0)