-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node:stream: fix setDefaultHighWaterMark (#14305)
- Loading branch information
Showing
2 changed files
with
42 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//#FILE: test-stream-set-default-hwm.js | ||
//#SHA1: bc1189f9270a4b5463d8421ef234fc7baaad667f | ||
//----------------- | ||
"use strict"; | ||
|
||
const { setDefaultHighWaterMark, getDefaultHighWaterMark, Writable, Readable, Transform } = require("stream"); | ||
|
||
test("setDefaultHighWaterMark and getDefaultHighWaterMark for object mode", () => { | ||
expect(getDefaultHighWaterMark(false)).not.toBe(32 * 1000); | ||
setDefaultHighWaterMark(false, 32 * 1000); | ||
expect(getDefaultHighWaterMark(false)).toBe(32 * 1000); | ||
}); | ||
|
||
test("setDefaultHighWaterMark and getDefaultHighWaterMark for non-object mode", () => { | ||
expect(getDefaultHighWaterMark(true)).not.toBe(32); | ||
setDefaultHighWaterMark(true, 32); | ||
expect(getDefaultHighWaterMark(true)).toBe(32); | ||
}); | ||
|
||
test("Writable stream uses new default high water mark", () => { | ||
const w = new Writable({ | ||
write() {}, | ||
}); | ||
expect(w.writableHighWaterMark).toBe(32 * 1000); | ||
}); | ||
|
||
test("Readable stream uses new default high water mark", () => { | ||
const r = new Readable({ | ||
read() {}, | ||
}); | ||
expect(r.readableHighWaterMark).toBe(32 * 1000); | ||
}); | ||
|
||
test("Transform stream uses new default high water mark for both readable and writable", () => { | ||
const t = new Transform({ | ||
transform() {}, | ||
}); | ||
expect(t.writableHighWaterMark).toBe(32 * 1000); | ||
expect(t.readableHighWaterMark).toBe(32 * 1000); | ||
}); | ||
|
||
//<#END_FILE: test-stream-set-default-hwm.js |