1 | var test = require('tape')
|
2 | var through = require('../')
|
3 |
|
4 |
|
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 |
|