mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { env } from "bun";
|
|
import { hasNonReifiedStatic } from "bun:internal-for-testing";
|
|
import { expect, test } from "bun:test";
|
|
test("hasNonReifiedStatic", () => {
|
|
expect(hasNonReifiedStatic(Bun), "do not eagerly initialize the Bun object. This will make Bun much slower.").toBe(
|
|
true,
|
|
);
|
|
expect(env.a).toBeUndefined();
|
|
expect(hasNonReifiedStatic(Bun), "do not eagerly initialize the Bun object. This will make Bun much slower.").toBe(
|
|
true,
|
|
);
|
|
const a = { ...Bun };
|
|
globalThis.a = a;
|
|
expect(hasNonReifiedStatic(Bun)).toBe(false);
|
|
});
|
|
|
|
test("require('bun')", () => {
|
|
const str = eval("'bun'");
|
|
expect(require(str)).toBe(Bun);
|
|
});
|
|
|
|
test("await import('bun')", async () => {
|
|
const str = eval("'bun'");
|
|
const BunESM = await import(str);
|
|
|
|
// console.log it so that we iterate through all the fields and crash if it's
|
|
// in an unexpected state.
|
|
console.log(BunESM);
|
|
|
|
for (let property in Bun) {
|
|
expect(BunESM).toHaveProperty(property);
|
|
expect(BunESM[property]).toBe(Bun[property]);
|
|
}
|
|
expect(BunESM.default).toBe(Bun);
|
|
});
|