xref: /third_party/node/test/parallel/test-stream-duplex-writable-finished.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst { Duplex } = require('stream');
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// basic
81cb0ef41Sopenharmony_ci{
91cb0ef41Sopenharmony_ci  // Find it on Duplex.prototype
101cb0ef41Sopenharmony_ci  assert(Object.hasOwn(Duplex.prototype, 'writableFinished'));
111cb0ef41Sopenharmony_ci}
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci// event
141cb0ef41Sopenharmony_ci{
151cb0ef41Sopenharmony_ci  const duplex = new Duplex();
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  duplex._write = (chunk, encoding, cb) => {
181cb0ef41Sopenharmony_ci    // The state finished should start in false.
191cb0ef41Sopenharmony_ci    assert.strictEqual(duplex.writableFinished, false);
201cb0ef41Sopenharmony_ci    cb();
211cb0ef41Sopenharmony_ci  };
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci  duplex.on('finish', common.mustCall(() => {
241cb0ef41Sopenharmony_ci    assert.strictEqual(duplex.writableFinished, true);
251cb0ef41Sopenharmony_ci  }));
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ci  duplex.end('testing finished state', common.mustCall(() => {
281cb0ef41Sopenharmony_ci    assert.strictEqual(duplex.writableFinished, true);
291cb0ef41Sopenharmony_ci  }));
301cb0ef41Sopenharmony_ci}
31

Indexes created Thu Nov 07 10:32:03 CST 2024