summaryrefslogtreecommitdiff
path: root/tests/node_compat/test/parallel/test-stream-writable-finished-state.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/node_compat/test/parallel/test-stream-writable-finished-state.js')
-rw-r--r--tests/node_compat/test/parallel/test-stream-writable-finished-state.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/node_compat/test/parallel/test-stream-writable-finished-state.js b/tests/node_compat/test/parallel/test-stream-writable-finished-state.js
new file mode 100644
index 000000000..0b7333bf2
--- /dev/null
+++ b/tests/node_compat/test/parallel/test-stream-writable-finished-state.js
@@ -0,0 +1,29 @@
+// 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 `tools/node_compat/setup.ts`. Do not modify this file manually.
+
+'use strict';
+
+const common = require('../common');
+
+const assert = require('assert');
+const stream = require('stream');
+
+const writable = new stream.Writable();
+
+writable._write = (chunk, encoding, cb) => {
+ // The state finished should start in false.
+ assert.strictEqual(writable._writableState.finished, false);
+ cb();
+};
+
+writable.on('finish', common.mustCall(() => {
+ assert.strictEqual(writable._writableState.finished, true);
+}));
+
+writable.end('testing finished state', common.mustCall(() => {
+ assert.strictEqual(writable._writableState.finished, true);
+}));