| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | var test = require('tape') |
| 2 | var through = require('../') |
| 3 | |
| 4 | // must emit end before close. |
| 5 | |
| 6 | test('end before close', function (assert) { |
| 7 | var ts = through() |
| 8 | ts.autoDestroy = false |
| 9 | var ended = false, closed = false |
| 10 | |
| 11 | ts.on('end', function () { |
| 12 | assert.ok(!closed) |
| 13 | ended = true |
| 14 | }) |
| 15 | ts.on('close', function () { |
| 16 | assert.ok(ended) |
| 17 | closed = true |
| 18 | }) |
| 19 | |
| 20 | ts.write(1) |
| 21 | ts.write(2) |
| 22 | ts.write(3) |
| 23 | ts.end() |
| 24 | assert.ok(ended) |
| 25 | assert.notOk(closed) |
| 26 | ts.destroy() |
| 27 | assert.ok(closed) |
| 28 | assert.end() |
| 29 | }) |
| 30 | |