-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test for received invokes method (#26)
- Loading branch information
Showing
1 changed file
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |