import { toHaveBeenCalledOnce } from "https://deno.land/x/unitest@v1.0.0-beta.82/matcher/to_have_been_called_once.ts";
Use .toHaveBeenCalledOnce
to check if a mock object was called exactly one
time
import {
defineExpect,
fn,
not,
test,
toHaveBeenCalledOnce,
} from "https://deno.land/x/unitest@$VERSION/mod.ts";
const expect = defineExpect({
matcherMap: {
toHaveBeenCalledOnce,
},
modifierMap: {
not,
},
});
test("passes only if mock object was called exactly once", () => {
const mockObject = fn();
mockObject();
expect(mockObject).toHaveBeenCalledOnce();
mockObject();
expect(mockObject).not.toHaveBeenCalledOnce();
});
Parameters
unnamed 0: MockObject