summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js')
-rw-r--r--deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js b/deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js
new file mode 100644
index 0000000000..305fff23d3
--- /dev/null
+++ b/deps/npm/node_modules/JSONStream/node_modules/through/test/auto-destroy.js
@@ -0,0 +1,29 @@
+var test = require('tape')
+var through = require('../')
+
+// must emit end before close.
+
+test('end before close', function (assert) {
+ var ts = through()
+ ts.autoDestroy = false
+ var ended = false, closed = false
+
+ ts.on('end', function () {
+ assert.ok(!closed)
+ ended = true
+ })
+ ts.on('close', function () {
+ assert.ok(ended)
+ closed = true
+ })
+
+ ts.write(1)
+ ts.write(2)
+ ts.write(3)
+ ts.end()
+ assert.ok(ended)
+ assert.notOk(closed)
+ ts.destroy()
+ assert.ok(closed)
+ assert.end()
+})