aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js')
-rw-r--r--test/js/node/child_process/child_process.test.ts23
1 files changed, 17 insertions, 6 deletions
diff --git a/test/js/node/child_process/child_process.test.ts b/test/js/node/child_process/child_process.test.ts
index 24b3b5e48..8c54a11c5 100644
--- a/test/js/node/child_process/child_process.test.ts
+++ b/test/js/node/child_process/child_process.test.ts
@@ -149,13 +149,24 @@ describe("spawn()", () => {
});
it("should allow us to set env", async () => {
- const child = spawn("env", { env: { TEST: "test" } });
- const result: string = await new Promise(resolve => {
- child.stdout.on("data", data => {
- resolve(data.toString());
+ async function getChildEnv(env: any): Promise<string> {
+ const child = spawn("env", { env: env });
+ const result: string = await new Promise(resolve => {
+ let output = "";
+ child.stdout.on("data", data => {
+ output += data;
+ });
+ child.stdout.on("end", () => {
+ resolve(output);
+ });
});
- });
- expect(/TEST\=test/.test(result)).toBe(true);
+ return result;
+ }
+
+ expect(/TEST\=test/.test(await getChildEnv({ TEST: "test" }))).toBe(true);
+ expect(await getChildEnv({})).toStrictEqual("");
+ expect(await getChildEnv(undefined)).not.toStrictEqual("");
+ expect(await getChildEnv(null)).not.toStrictEqual("");
});
it("should allow explicit setting of argv0", async () => {