(sync)
| 29 | runTests(true); |
| 30 | |
| 31 | function runTests(sync) { |
| 32 | { |
| 33 | const dest = getTempFile(); |
| 34 | const fd = openSync(dest, 'w'); |
| 35 | const stream = new Utf8Stream({ fd, sync }); |
| 36 | stream.on('ready', common.mustCall(() => { |
| 37 | assert.ok(stream.write('hello world\n')); |
| 38 | assert.ok(stream.write('something else\n')); |
| 39 | |
| 40 | stream.end(); |
| 41 | |
| 42 | stream.on('finish', common.mustCall(() => { |
| 43 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 44 | assert.strictEqual(data, 'hello world\nsomething else\n'); |
| 45 | })); |
| 46 | })); |
| 47 | })); |
| 48 | } |
| 49 | |
| 50 | { |
| 51 | const dest = getTempFile(); |
| 52 | const fd = openSync(dest, 'w'); |
| 53 | const stream = new Utf8Stream({ fd, sync }); |
| 54 | |
| 55 | stream.once('drain', common.mustCall(() => { |
| 56 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 57 | assert.strictEqual(data, 'hello world\n'); |
| 58 | assert.ok(stream.write('something else\n')); |
| 59 | |
| 60 | stream.once('drain', common.mustCall(() => { |
| 61 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 62 | assert.strictEqual(data, 'hello world\nsomething else\n'); |
| 63 | stream.end(); |
| 64 | })); |
| 65 | })); |
| 66 | })); |
| 67 | })); |
| 68 | |
| 69 | assert.ok(stream.write('hello world\n')); |
| 70 | }; |
| 71 | |
| 72 | { |
| 73 | const dest = getTempFile(); |
| 74 | const fd = openSync(dest, 'w'); |
| 75 | const stream = new Utf8Stream({ fd, sync }); |
| 76 | const source = createReadStream(__filename, { encoding: 'utf8' }); |
| 77 | |
| 78 | source.pipe(stream); |
| 79 | |
| 80 | stream.on('finish', common.mustCall(() => { |
| 81 | readFile(__filename, 'utf8', common.mustSucceed((expected) => { |
| 82 | readFile(dest, 'utf8', common.mustSucceed((data) => { |
| 83 | assert.strictEqual(data, expected); |
| 84 | })); |
| 85 | })); |
| 86 | })); |
| 87 | } |
| 88 |
no test coverage detected
searching dependent graphs…