mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import * as CJSArrayLike from "./cjs-defineProperty-arraylike.cjs";
|
|
import * as CJS from "./cjs-defineProperty-fixture.cjs";
|
|
// https://github.com/oven-sh/bun/issues/4432
|
|
test("defineProperty", () => {
|
|
expect(CJS.a).toBe(1);
|
|
expect(CJS.b).toBe(2);
|
|
// non-enumerable getter/setter are not copied, matching node.js
|
|
expect(CJS.c).toBe(undefined);
|
|
|
|
expect(Bun.inspect(CJS.default)).toBe(`{\n a: 1,\n b: 2,\n c: [Getter],\n}`);
|
|
});
|
|
import * as Self from "./esm-defineProperty.test.ts";
|
|
export const __esModule = true;
|
|
test("shows __esModule if it was exported", () => {
|
|
expect(Bun.inspect(Self)).toBe(`Module {
|
|
__esModule: true,
|
|
}`);
|
|
expect(Object.getOwnPropertyNames(Self)).toContain("__esModule");
|
|
});
|
|
|
|
test("arraylike", () => {
|
|
expect(CJSArrayLike[0]).toBe(0);
|
|
expect(CJSArrayLike[1]).toBe(1);
|
|
expect(CJSArrayLike[2]).toBe(3);
|
|
expect(CJSArrayLike[3]).toBe(4);
|
|
expect(CJSArrayLike[4]).toBe(undefined);
|
|
expect(CJSArrayLike).toHaveProperty("4");
|
|
expect(Object.getOwnPropertyNames(CJSArrayLike)).not.toContain("__esModule");
|
|
expect(Object.getOwnPropertyNames(CJSArrayLike.default)).not.toContain("__esModule");
|
|
expect(Bun.inspect(CJSArrayLike)).toBe(`Module {
|
|
"0": 0,
|
|
"1": 1,
|
|
"2": 3,
|
|
"3": 4,
|
|
"4": undefined,
|
|
default: {
|
|
"0": 0,
|
|
"1": 1,
|
|
"2": [Getter],
|
|
"3": 4,
|
|
"4": [Getter],
|
|
},
|
|
}`);
|
|
});
|