diff options
author | 2022-06-22 23:21:48 -0700 | |
---|---|---|
committer | 2022-06-22 23:21:48 -0700 | |
commit | 729d445b6885f69dd2c6355f38707bd42851c791 (patch) | |
tree | f87a7c408929ea3f57bbb7ace380cf869da83c0e /test/bun.js/process.test.js | |
parent | 25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff) | |
download | bun-729d445b6885f69dd2c6355f38707bd42851c791.tar.gz bun-729d445b6885f69dd2c6355f38707bd42851c791.tar.zst bun-729d445b6885f69dd2c6355f38707bd42851c791.zip |
change the directory structurejarred/rename
Diffstat (limited to 'test/bun.js/process.test.js')
-rw-r--r-- | test/bun.js/process.test.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/bun.js/process.test.js b/test/bun.js/process.test.js new file mode 100644 index 000000000..f82834a04 --- /dev/null +++ b/test/bun.js/process.test.js @@ -0,0 +1,54 @@ +import { describe, it } from "bun:test"; + +it("process", () => { + // this property isn't implemented yet but it should at least return a string + const isNode = !process.isBun; + + if (!isNode && process.title !== "bun") + throw new Error("process.title is not 'bun'"); + + if (typeof process.env.USER !== "string") + throw new Error("process.env is not an object"); + + if (process.env.USER.length === 0) + throw new Error("process.env is missing a USER property"); + + if (process.platform !== "darwin" && process.platform !== "linux") + throw new Error("process.platform is invalid"); + + if (isNode) throw new Error("process.isBun is invalid"); + + // partially to test it doesn't crash due to various strange types + process.env.BACON = "yummy"; + if (process.env.BACON !== "yummy") { + throw new Error("process.env is not writable"); + } + + delete process.env.BACON; + if (typeof process.env.BACON !== "undefined") { + throw new Error("process.env is not deletable"); + } + + process.env.BACON = "yummy"; + if (process.env.BACON !== "yummy") { + throw new Error("process.env is not re-writable"); + } + + if (JSON.parse(JSON.stringify(process.env)).BACON !== "yummy") { + throw new Error("process.env is not serializable"); + } + + if (typeof JSON.parse(JSON.stringify(process.env)).toJSON !== "undefined") { + throw new Error( + "process.env should call toJSON to hide its internal state" + ); + } + + var { env, ...proces } = process; + console.log(JSON.stringify(proces, null, 2)); + console.log(proces); + + console.log("CWD", process.cwd()); + console.log("SET CWD", process.chdir("../")); + console.log("CWD", process.cwd()); +}); |