summaryrefslogtreecommitdiff
path: root/tests/node_compat
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-06-25 15:06:40 +0530
committerGitHub <noreply@github.com>2024-06-25 09:36:40 +0000
commitb71a85918815195a2a8ba070fb534e50938251bd (patch)
tree8fc97d76345b532183393f7ba3d5aa2666a7fa4c /tests/node_compat
parent1e8a6b94b1dcf98a2ae4de97b3e98e7b3e4e8f7f (diff)
test(node_compat): enable more stream-writable tests (#24328)
Diffstat (limited to 'tests/node_compat')
-rw-r--r--tests/node_compat/config.jsonc4
-rw-r--r--tests/node_compat/runner/TODO.md4
-rw-r--r--tests/node_compat/test/parallel/test-stream-writable-aborted.js33
-rw-r--r--tests/node_compat/test/parallel/test-stream-writable-final-async.js32
-rw-r--r--tests/node_compat/test/parallel/test-stream-writable-final-destroy.js28
-rw-r--r--tests/node_compat/test/parallel/test-stream-writable-final-throw.js30
6 files changed, 127 insertions, 4 deletions
diff --git a/tests/node_compat/config.jsonc b/tests/node_compat/config.jsonc
index 83d91eac1..638af89c8 100644
--- a/tests/node_compat/config.jsonc
+++ b/tests/node_compat/config.jsonc
@@ -575,6 +575,7 @@
"test-stream-unpipe-event.js",
"test-stream-unshift-empty-chunk.js",
"test-stream-unshift-read-race.js",
+ "test-stream-writable-aborted.js",
"test-stream-writable-change-default-encoding.js",
"test-stream-writable-clear-buffer.js",
"test-stream-writable-constructor-set-methods.js",
@@ -583,6 +584,9 @@
"test-stream-writable-end-cb-error.js",
"test-stream-writable-end-multiple.js",
"test-stream-writable-ended-state.js",
+ "test-stream-writable-final-async.js",
+ "test-stream-writable-final-destroy.js",
+ "test-stream-writable-final-throw.js",
"test-stream-writable-finish-destroyed.js",
"test-stream-writable-finished-state.js",
"test-stream-writable-finished.js",
diff --git a/tests/node_compat/runner/TODO.md b/tests/node_compat/runner/TODO.md
index 24618dc88..0a68b810f 100644
--- a/tests/node_compat/runner/TODO.md
+++ b/tests/node_compat/runner/TODO.md
@@ -2298,11 +2298,7 @@ NOTE: This file should not be manually edited. Please edit `tests/node_compat/co
- [parallel/test-stream-wrap-drain.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap-drain.js)
- [parallel/test-stream-wrap-encoding.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap-encoding.js)
- [parallel/test-stream-wrap.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-wrap.js)
-- [parallel/test-stream-writable-aborted.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-aborted.js)
- [parallel/test-stream-writable-end-cb-uncaught.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-end-cb-uncaught.js)
-- [parallel/test-stream-writable-final-async.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-async.js)
-- [parallel/test-stream-writable-final-destroy.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-destroy.js)
-- [parallel/test-stream-writable-final-throw.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-final-throw.js)
- [parallel/test-stream-writable-samecb-singletick.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream-writable-samecb-singletick.js)
- [parallel/test-stream2-finish-pipe-error.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream2-finish-pipe-error.js)
- [parallel/test-stream2-httpclient-response-end.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-stream2-httpclient-response-end.js)
diff --git a/tests/node_compat/test/parallel/test-stream-writable-aborted.js b/tests/node_compat/test/parallel/test-stream-writable-aborted.js
new file mode 100644
index 000000000..89dbcc4ee
--- /dev/null
+++ b/tests/node_compat/test/parallel/test-stream-writable-aborted.js
@@ -0,0 +1,33 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+require('../common');
+const assert = require('assert');
+const { Writable } = require('stream');
+
+{
+ const writable = new Writable({
+ write() {
+ }
+ });
+ assert.strictEqual(writable.writableAborted, false);
+ writable.destroy();
+ assert.strictEqual(writable.writableAborted, true);
+}
+
+{
+ const writable = new Writable({
+ write() {
+ }
+ });
+ assert.strictEqual(writable.writableAborted, false);
+ writable.end();
+ writable.destroy();
+ assert.strictEqual(writable.writableAborted, true);
+}
diff --git a/tests/node_compat/test/parallel/test-stream-writable-final-async.js b/tests/node_compat/test/parallel/test-stream-writable-final-async.js
new file mode 100644
index 000000000..c8fe2057b
--- /dev/null
+++ b/tests/node_compat/test/parallel/test-stream-writable-final-async.js
@@ -0,0 +1,32 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+const common = require('../common');
+const {
+ Duplex,
+} = require('stream');
+const { setTimeout } = require('timers/promises');
+
+{
+ class Foo extends Duplex {
+ async _final(callback) {
+ await setTimeout(common.platformTimeout(1));
+ callback();
+ }
+
+ _read() {}
+ }
+
+ const foo = new Foo();
+ foo._write = common.mustCall((chunk, encoding, cb) => {
+ cb();
+ });
+ foo.end('test', common.mustCall());
+ foo.on('error', common.mustNotCall());
+}
diff --git a/tests/node_compat/test/parallel/test-stream-writable-final-destroy.js b/tests/node_compat/test/parallel/test-stream-writable-final-destroy.js
new file mode 100644
index 000000000..958a36bfd
--- /dev/null
+++ b/tests/node_compat/test/parallel/test-stream-writable-final-destroy.js
@@ -0,0 +1,28 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+const common = require('../common');
+
+const { Writable } = require('stream');
+
+{
+ const w = new Writable({
+ write(chunk, encoding, callback) {
+ callback(null);
+ },
+ final(callback) {
+ queueMicrotask(callback);
+ }
+ });
+ w.end();
+ w.destroy();
+
+ w.on('prefinish', common.mustNotCall());
+ w.on('finish', common.mustNotCall());
+ w.on('close', common.mustCall());
+}
diff --git a/tests/node_compat/test/parallel/test-stream-writable-final-throw.js b/tests/node_compat/test/parallel/test-stream-writable-final-throw.js
new file mode 100644
index 000000000..ba7f87b23
--- /dev/null
+++ b/tests/node_compat/test/parallel/test-stream-writable-final-throw.js
@@ -0,0 +1,30 @@
+// deno-fmt-ignore-file
+// deno-lint-ignore-file
+
+// Copyright Joyent and Node contributors. All rights reserved. MIT license.
+// Taken from Node 18.12.1
+// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+const common = require('../common');
+const {
+ Duplex,
+} = require('stream');
+
+{
+ class Foo extends Duplex {
+ _final(callback) {
+ throw new Error('fhqwhgads');
+ }
+
+ _read() {}
+ }
+
+ const foo = new Foo();
+ foo._write = common.mustCall((chunk, encoding, cb) => {
+ cb();
+ });
+ foo.end('test', common.expectsError({ message: 'fhqwhgads' }));
+ foo.on('error', common.mustCall());
+}