|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | +const { Readable, Writable, Duplex } = require('stream'); |
| 6 | + |
| 7 | +{ |
| 8 | + const stream = new Readable(); |
| 9 | + assert.strictEqual(stream.eventNames().length, 0); |
| 10 | +} |
| 11 | + |
| 12 | +{ |
| 13 | + const stream = new Readable(); |
| 14 | + stream.on('foo', () => {}); |
| 15 | + stream.on('data', () => {}); |
| 16 | + stream.on('error', () => {}); |
| 17 | + assert.deepStrictEqual(stream.eventNames(), ['error', 'data', 'foo']); |
| 18 | +} |
| 19 | + |
| 20 | +{ |
| 21 | + const stream = new Writable(); |
| 22 | + assert.strictEqual(stream.eventNames().length, 0); |
| 23 | +} |
| 24 | + |
| 25 | +{ |
| 26 | + const stream = new Writable(); |
| 27 | + stream.on('foo', () => {}); |
| 28 | + stream.on('drain', () => {}); |
| 29 | + stream.on('prefinish', () => {}); |
| 30 | + assert.deepStrictEqual(stream.eventNames(), ['prefinish', 'drain', 'foo']); |
| 31 | +} |
| 32 | +{ |
| 33 | + const stream = new Duplex(); |
| 34 | + assert.strictEqual(stream.eventNames().length, 0); |
| 35 | +} |
| 36 | + |
| 37 | +{ |
| 38 | + const stream = new Duplex(); |
| 39 | + stream.on('foo', () => {}); |
| 40 | + stream.on('finish', () => {}); |
| 41 | + assert.deepStrictEqual(stream.eventNames(), ['finish', 'foo']); |
| 42 | +} |
0 commit comments