mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
5803cc9172
* BREAKING(assert): remove `assert` from module names * work * fix * work * work * tweaks * fix
31 lines
802 B
TypeScript
31 lines
802 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assertThrows } from "@std/assert";
|
|
import { expect } from "./expect.ts";
|
|
import { fn } from "./fn.ts";
|
|
|
|
Deno.test("expect().toHaveBeenCalled() checks the mock call", () => {
|
|
const mockFn = fn();
|
|
mockFn();
|
|
|
|
expect(mockFn).toHaveBeenCalled();
|
|
|
|
assertThrows(
|
|
() => expect(mockFn).not.toHaveBeenCalled(),
|
|
Error,
|
|
"Expected mock function not to be called, but it was called 1 time(s)",
|
|
);
|
|
});
|
|
|
|
Deno.test("expect().toHaveBeenCalled() handles the case when the mock is not called", () => {
|
|
const mockFn = fn();
|
|
|
|
expect(mockFn).not.toHaveBeenCalled();
|
|
|
|
assertThrows(
|
|
() => expect(mockFn).toHaveBeenCalled(),
|
|
Error,
|
|
"Expected mock function to be called, but it was not called",
|
|
);
|
|
});
|