Skip to content

Commit

Permalink
Update test for received invokes method (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
thrixton authored and ffMathy committed Mar 6, 2019
1 parent a46c9a4 commit 2957aea
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions spec/issues/23.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import test from 'ava';
import test from "ava";

import { Substitute, Arg } from '../../src/Index';
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
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>();
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;
});
mockedCalculator.add(Arg.all()).mimicks((a, b) => {
t.deepEqual(a, 1);
return a + b;
});

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

t.is(result, 0);
});
mockedCalculator.received(1).add(2, 1); // not ok, calls mimick func
});

0 comments on commit 2957aea

Please sign in to comment.