Skip to content

Commit f67cf2f

Browse files
renatomariscalffMathy
authored andcommitted
Add issue 51 (#53)
1 parent 1e9f15c commit f67cf2f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/issues/51.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import test from 'ava';
2+
3+
import { Substitute, Arg } from '../../src/index';
4+
5+
interface ICalculator {
6+
add(a: number, b: number): number;
7+
divide(a: number, b: number): number;
8+
}
9+
test('issue 51 - All functions shares the same state', async t => {
10+
const calculator = Substitute.for<ICalculator>();
11+
calculator.add(1, 2).returns(4);
12+
13+
const result = calculator.add(1, 2);
14+
t.is(result, 4);
15+
try {
16+
calculator.received().divide(1, 2);
17+
t.fail('Expected to have failed.');
18+
} catch (e) {
19+
t.regex(e.toString(), /Expected 1 or more calls to the property divide with no arguments/);
20+
}
21+
});

0 commit comments

Comments
 (0)