Add test for spyOn + ESM namespace

This commit is contained in:
Jarred Sumner
2023-10-24 06:21:14 -07:00
parent 3a0d7fc3f0
commit 39ce95c0d0
2 changed files with 12 additions and 1 deletions

View File

@@ -7,8 +7,16 @@
// - Write test for export {foo} from "./foo"
// - Write test for import {foo} from "./foo"; export {foo}
import { mock, test, expect } from "bun:test";
import { mock, test, expect, spyOn, Mock } from "bun:test";
import { fn, iCallFn, variable } from "./mock-module-fixture";
import * as spyFixture from "./spymodule-fixture";
test("spyOn", () => {
spyOn(spyFixture, "iSpy");
expect(spyFixture.iSpy).not.toHaveBeenCalled();
spyFixture.iSpy(123);
expect(spyFixture.iSpy).toHaveBeenCalled();
});
test("mocking a local file", async () => {
expect(fn()).toEqual(42);

View File

@@ -0,0 +1,3 @@
export function iSpy(_) {
return 42;
}