Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d4ba9bb

Browse files
committed
feat: add test for onLine throw error
1 parent 0bc9698 commit d4ba9bb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎test/unit/node/util.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,28 @@ describe("onLine", () => {
447447

448448
expect(await received).toEqual(expected)
449449
})
450+
451+
describe("used with a process missing stdout ", () => {
452+
it("should throw an error", async () => {
453+
// Initialize a process that does not have stdout.
454+
// "If the child was spawned with stdio set to anything
455+
// other than 'pipe', then subprocess.stdout will be null."
456+
// Source: https://stackoverflow.com/a/46024006/3015595
457+
// Other source: https://nodejs.org/api/child_process.html#child_process_subprocess_stdout
458+
// NOTE@jsjoeio - I'm not sure if this actually happens though
459+
// which is why I have to set proc.stdout = null
460+
// a couple lines below.
461+
const proc = cp.spawn("node", [], {
462+
stdio: "ignore",
463+
})
464+
const mockCallback = jest.fn()
465+
466+
expect(() => util.onLine(proc, mockCallback)).toThrowError(/stdout/)
467+
468+
// Cleanup
469+
proc?.kill()
470+
})
471+
})
450472
})
451473

452474
describe("escapeHtml", () => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /