Skip to content

Commit

Permalink
Add tests for toHaveReturnedWith
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRamosAcosta committed May 9, 2020
1 parent 207eacf commit a458143
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

25 changes: 24 additions & 1 deletion matchers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
toHaveBeenCalledWith,
toHaveBeenLastCalledWith,
toHaveBeenNthCalledWith,
toHaveReturnedWith,
} from "./matchers.ts";

function assertResult(actual: MatchResult, expected: MatchResult) {
Expand Down Expand Up @@ -577,7 +578,29 @@ Deno.test({
},
});

//TODO(allain) - toHaveReturnedWith(value: any, result: any): MatchResult
Deno.test({
name: "toHaveReturnedWithPass",
fn: () => {
const m = mock.fn(() => true);
m();
assertResultPass(toHaveReturnedWith(m, true));
},
});

Deno.test({
name: "toHaveReturnedWithFail",
fn: () => {
const m = mock.fn(() => true);
m();
assertResult(toHaveReturnedWith(m, false), {
pass: false,
message: `expect(actual).toHaveReturnedWith(expected)
function did not return: false`,
});
},
});

//TODO(allain) - toHaveReturned(value: any): MatchResult
//TODO(allain) - toHaveLastReturnedWith(value: any, expected: any): MatchResult
//TODO(allain) - toHaveReturnedTimes(value: any, times: number): MatchResult
Expand Down

0 comments on commit a458143

Please sign in to comment.