2024-02-28 04:07:50 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
import { expect } from "./expect.ts";
|
2024-04-29 02:57:30 +00:00
|
|
|
import { AssertionError, assertThrows } from "@std/assert";
|
2024-02-28 04:07:50 +00:00
|
|
|
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());
|
|
|
|
});
|