diff options
author | 2022-12-02 10:25:13 -0600 | |
---|---|---|
committer | 2022-12-02 08:25:13 -0800 | |
commit | b8586b33dad8ab66ebd5d1aa4d5a0df305266e7f (patch) | |
tree | 19c31806b3ae22d7c0f0f127fd3cb1b640f4bd59 /test/bun.js/node-test-helpers.test.js | |
parent | beaf91590acd319e4ac15c14c64c59f45b6a794b (diff) | |
download | bun-b8586b33dad8ab66ebd5d1aa4d5a0df305266e7f.tar.gz bun-b8586b33dad8ab66ebd5d1aa4d5a0df305266e7f.tar.zst bun-b8586b33dad8ab66ebd5d1aa4d5a0df305266e7f.zip |
feat(process): add process.{stdin, stdout, stderr} support (#1495)
* fix(stream): get Duplex working
* feat(process): add stdin,stdout,stderr in a semi-broken state (pipes??)
* test(NodeTestHelpers): fix test names
* test(NodeTestHelpers): add test for createDoneDotAll done called w error
* test(NodeTestHelpers): remove stray console.log
* fix(stream): fix bug in Duplex, Readable
* test(process.stdio): rename test
* fix(process.stdio): change onData listener to onReadable
* refactor(streams): add file-wide debug fn, destructure opts
* fix(child_process): check isCallable on promise
* fix: get stdio streams mostly working (mostly)
* fix(child_process): wait until stream is drained before calling end?
* fix(child_process): change to result?.then
* debug(child_process,streams): add EE id tracking, add shim for stdio after handle is dead
* test(child_process): fix double pipe test, temp fix for ChildProcess.kill() return val
* fix(child_process): remove immediate emit of exit on kill
* debug(streams): add more debug log
* debug(streams): add more debug logs part 2
* feat(streams,fs): add NativeWritable, adapt fs.WriteStream and fs.ReadStream to native
Diffstat (limited to 'test/bun.js/node-test-helpers.test.js')
-rw-r--r-- | test/bun.js/node-test-helpers.test.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/test/bun.js/node-test-helpers.test.js b/test/bun.js/node-test-helpers.test.js index 766dfc176..30ee4932d 100644 --- a/test/bun.js/node-test-helpers.test.js +++ b/test/bun.js/node-test-helpers.test.js @@ -7,7 +7,7 @@ import { createDoneDotAll, } from "./node-test-helpers"; -describe("OurAssert.throws()", () => { +describe("NodeTestHelpers.throws()", () => { it("should pass when the function throws", () => { throws(() => { throw new Error("THROWN!"); @@ -22,12 +22,11 @@ describe("OurAssert.throws()", () => { err = e; } - console.log(err.code); expect(err instanceof Error).toBe(true); }); }); -describe("OurAssert.assert()", () => { +describe("NodeTestHelpers.assert()", () => { it("should pass when the provided value is true", () => { assert(true); }); @@ -43,7 +42,7 @@ describe("OurAssert.assert()", () => { }); }); -describe("OurAssert.strictEqual()", () => { +describe("NodeTestHelpers.strictEqual()", () => { it("should pass when the provided values are deeply equal", () => { strictEqual(1, 1); strictEqual("hello", "hello"); @@ -92,7 +91,7 @@ describe("OurAssert.strictEqual()", () => { }); }); -describe("OurAssert.createCallCheckCtx", () => { +describe("NodeTestHelpers.createCallCheckCtx", () => { it("should pass when all mustCall marked callbacks have been called", (done) => { const { mustCall } = createCallCheckCtx(done); const fn1 = mustCall(() => {}); @@ -122,7 +121,7 @@ describe("OurAssert.createCallCheckCtx", () => { }); }); -describe("OurAssert.createDoneDotAll()", () => { +describe("NodeTestHelpers.createDoneDotAll()", () => { it("should pass when all dones have been called", (done) => { const createDone = createDoneDotAll(done); const done1 = createDone(600); @@ -154,4 +153,17 @@ describe("OurAssert.createDoneDotAll()", () => { setTimeout(() => fn1(), 200); setTimeout(() => fn2(), 200); }); + + it("should fail if a done is called with an error", (done) => { + const mockDone = (result) => { + expect(result instanceof Error).toBe(true); + done(); + }; + const createDone = createDoneDotAll(mockDone); + + const done1 = createDone(600); + const done2 = createDone(600); + setTimeout(() => done1(), 300); + setTimeout(() => done2(new Error("ERROR!")), 450); + }); }); |