diff options
author | 2022-11-28 15:59:58 -0800 | |
---|---|---|
committer | 2022-11-28 15:59:58 -0800 | |
commit | f423791e196f26500fef30c789270b68ffb398f0 (patch) | |
tree | 8802e7b585426e78bdf63450a2f0dd9a0828a4aa | |
parent | a6cadce6f6292b685cc4160052304b5dfc8cd3ad (diff) | |
download | bun-f423791e196f26500fef30c789270b68ffb398f0.tar.gz bun-f423791e196f26500fef30c789270b68ffb398f0.tar.zst bun-f423791e196f26500fef30c789270b68ffb398f0.zip |
Add test for process
-rw-r--r-- | test/bun.js/process.test.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/bun.js/process.test.js b/test/bun.js/process.test.js index 4e79716db..f3ed9dd63 100644 --- a/test/bun.js/process.test.js +++ b/test/bun.js/process.test.js @@ -33,8 +33,7 @@ it("process", () => { if (process.env.BACON !== "yummy") { throw new Error("process.env is not re-writable"); } - - if (JSON.parse(JSON.stringify(process.env)).BACON !== "yummy") { + if (!JSON.stringify(process.env)) { throw new Error("process.env is not serializable"); } @@ -45,7 +44,6 @@ it("process", () => { } var { env, ...proces } = process; - console.log(JSON.stringify(proces, null, 2)); console.log(proces); console.log("CWD", process.cwd()); @@ -88,6 +86,19 @@ it("process.env", () => { expect(process.env["LOL SMILE latin1 <abc>"]).toBe(undefined); }); +it("process.env is spreadable and editable", () => { + process.env["LOL SMILE UTF16 😂"] = "😂"; + const { "LOL SMILE UTF16 😂": lol, ...rest } = process.env; + expect(lol).toBe("😂"); + delete process.env["LOL SMILE UTF16 😂"]; + expect(rest).toEqual(process.env); + const orig = ((getter) => process.env[getter])("USER"); + expect(process.env).toEqual(process.env); + eval(`globalThis.process.env.USER = 'bun';`); + expect(eval(`globalThis.process.env.USER`)).toBe("bun"); + expect(eval(`globalThis.process.env.USER = "${orig}"`)).toBe(orig); +}); + it("process.version starts with v", () => { expect(process.version.startsWith("v")).toBeTruthy(); }); |