-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac82d73
commit 112f793
Showing
4 changed files
with
44 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { expect } from "./expect.ts"; | ||
import { AssertionError, assertThrows } from "../assert/mod.ts"; | ||
import { fn } from "./fn.ts"; | ||
|
||
Deno.test("expect.anything() as a parameter of toEqual()", () => { | ||
expect(null).not.toEqual(expect.anything()); | ||
expect(undefined).not.toEqual(expect.anything()); | ||
expect(1).toEqual(expect.anything()); | ||
|
||
assertThrows(() => { | ||
expect(null).toEqual(expect.anything()); | ||
}, AssertionError); | ||
assertThrows(() => { | ||
expect(undefined).toEqual(expect.anything()); | ||
}, AssertionError); | ||
assertThrows(() => { | ||
expect(1).not.toEqual(expect.anything()); | ||
}, AssertionError); | ||
}); | ||
|
||
Deno.test("expect.anything() as a parameter of toHaveBeenCalled()", () => { | ||
const mockFn = fn(); | ||
mockFn(3); | ||
expect(mockFn).toHaveBeenCalledWith(expect.anything()); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class Anything { | ||
equals(other: unknown): boolean { | ||
return other !== null && other !== undefined; | ||
} | ||
} | ||
|
||
export function anything(): Anything { | ||
return new Anything(); | ||
} |
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
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