mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +01:00
e2e2bc83c0
Replace Object.prototpye.hasOwnProperty() with Object.hasOwn() where applicable. PR-URL: https://github.com/nodejs/node/pull/41664 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
31 lines
680 B
JavaScript
31 lines
680 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { Duplex } = require('stream');
|
|
const assert = require('assert');
|
|
|
|
// basic
|
|
{
|
|
// Find it on Duplex.prototype
|
|
assert(Object.hasOwn(Duplex.prototype, 'writableFinished'));
|
|
}
|
|
|
|
// event
|
|
{
|
|
const duplex = new Duplex();
|
|
|
|
duplex._write = (chunk, encoding, cb) => {
|
|
// The state finished should start in false.
|
|
assert.strictEqual(duplex.writableFinished, false);
|
|
cb();
|
|
};
|
|
|
|
duplex.on('finish', common.mustCall(() => {
|
|
assert.strictEqual(duplex.writableFinished, true);
|
|
}));
|
|
|
|
duplex.end('testing finished state', common.mustCall(() => {
|
|
assert.strictEqual(duplex.writableFinished, true);
|
|
}));
|
|
}
|