source: trip-planner-front/node_modules/through/test/end.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 707 bytes
Line 
1var test = require('tape')
2var through = require('../')
3
4// must emit end before close.
5
6test('end before close', function (assert) {
7 var ts = through()
8 var ended = false, closed = false
9
10 ts.on('end', function () {
11 assert.ok(!closed)
12 ended = true
13 })
14 ts.on('close', function () {
15 assert.ok(ended)
16 closed = true
17 })
18
19 ts.write(1)
20 ts.write(2)
21 ts.write(3)
22 ts.end()
23 assert.ok(ended)
24 assert.ok(closed)
25 assert.end()
26})
27
28test('end only once', function (t) {
29
30 var ts = through()
31 var ended = false, closed = false
32
33 ts.on('end', function () {
34 t.equal(ended, false)
35 ended = true
36 })
37
38 ts.queue(null)
39 ts.queue(null)
40 ts.queue(null)
41
42 ts.resume()
43
44 t.end()
45})
Note: See TracBrowser for help on using the repository browser.