mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Add test for spyOn + ESM namespace
This commit is contained in:
@@ -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);
|
||||
|
||||
3
test/js/bun/test/mock/spymodule-fixture.ts
Normal file
3
test/js/bun/test/mock/spymodule-fixture.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function iSpy(_) {
|
||||
return 42;
|
||||
}
|
||||
Reference in New Issue
Block a user