Skip to content

Commit e01c793

Browse files
Evgeny ShevchenkoffMathy
authored andcommitted
Add tests for didNotReceive #72 (#73)
1 parent d7f962b commit e01c793

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

spec/issues/72.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import test from "ava";
2+
3+
import { Substitute, Arg } from "../../src/index";
4+
5+
interface Calculator {
6+
add(a: number, b: number): number;
7+
subtract(a: number, b: number): number;
8+
divide(a: number, b: number): number;
9+
10+
isEnabled: boolean;
11+
}
12+
13+
test("check didNotReceive after not mocking and not calling a method", () => {
14+
const calculator = Substitute.for<Calculator>();
15+
16+
// Do not mock and do not call
17+
calculator.didNotReceive().add(1, 2);
18+
calculator.didNotReceive().add(Arg.any(), Arg.any());
19+
calculator.didNotReceive().add(1, Arg.any());
20+
});
21+
22+
test("check didNotReceive after not mocking but calling a method", () => {
23+
const calculator = Substitute.for<Calculator>();
24+
25+
// Do not mock, but call
26+
calculator.add(1, 2);
27+
calculator.didNotReceive().add(1, 2);
28+
calculator.didNotReceive().add(Arg.any(), Arg.any());
29+
calculator.didNotReceive().add(1, Arg.any());
30+
});
31+
32+
test("check didNotReceive after mocking but not calling a method", () => {
33+
const calculator = Substitute.for<Calculator>();
34+
35+
// Mock but do not call
36+
calculator.add(1, 2).returns(3);
37+
calculator.didNotReceive().add(1, 2);
38+
calculator.didNotReceive().add(Arg.any(), Arg.any());
39+
calculator.didNotReceive().add(1, Arg.any());
40+
});
41+
42+
test("check didNotReceive after mocking and calling a method", () => {
43+
const calculator = Substitute.for<Calculator>();
44+
45+
// Mock and call
46+
calculator.add(1, 2).returns(3);
47+
calculator.add(1, 2);
48+
calculator.didNotReceive().add(1, 2);
49+
calculator.didNotReceive().add(Arg.any(), Arg.any());
50+
calculator.didNotReceive().add(1, Arg.any());
51+
});

0 commit comments

Comments
 (0)