diff options
Diffstat (limited to 'std/node/process_test.ts')
-rw-r--r-- | std/node/process_test.ts | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/std/node/process_test.ts b/std/node/process_test.ts index 058105a4a..043a954f8 100644 --- a/std/node/process_test.ts +++ b/std/node/process_test.ts @@ -1,10 +1,30 @@ import { assert, assertThrows, assertEquals } from "../testing/asserts.ts"; -import { process } from "./process.ts"; +import * as all from "./process.ts"; +import { env, argv } from "./process.ts"; // NOTE: Deno.execPath() (and thus process.argv) currently requires --allow-env // (Also Deno.env.toObject() (and process.env) requires --allow-env but it's more obvious) Deno.test({ + name: "process exports are as they should be", + fn() { + // * should be the same as process, default, and globalThis.process + // without the export aliases, and with properties that are not standalone + const allKeys = new Set<string>(Object.keys(all)); + // without { process } for deno b/c + allKeys.delete("process"); + // without esm default + allKeys.delete("default"); + // with on, which is not exported via * + allKeys.add("on"); + const allStr = Array.from(allKeys).sort().join(" "); + assertEquals(Object.keys(all.default).sort().join(" "), allStr); + assertEquals(Object.keys(all.process).sort().join(" "), allStr); + assertEquals(Object.keys(process).sort().join(" "), allStr); + }, +}); + +Deno.test({ name: "process.cwd and process.chdir success", fn() { // this should be run like other tests from directory up @@ -82,8 +102,9 @@ Deno.test({ Deno.test({ name: "process.argv", - fn() { + async fn() { assert(Array.isArray(process.argv)); + assert(Array.isArray(await argv)); assert( process.argv[0].match(/[^/\\]*deno[^/\\]*$/), "deno included in the file name of argv[0]" @@ -94,7 +115,8 @@ Deno.test({ Deno.test({ name: "process.env", - fn() { + async fn() { assertEquals(typeof process.env.PATH, "string"); + assertEquals(typeof (await env).PATH, "string"); }, }); |