summaryrefslogtreecommitdiff
path: root/node_modules/simple-concat/test/basic.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:37:42 -0700
committer8cy <[email protected]>2020-04-03 02:37:42 -0700
commit60867fb030bae582082340ead7dbc7efdc2f5398 (patch)
tree4c6a7356351be2e4914e15c4703172597c45656e /node_modules/simple-concat/test/basic.js
parentcommenting (diff)
downloads5nical-60867fb030bae582082340ead7dbc7efdc2f5398.tar.xz
s5nical-60867fb030bae582082340ead7dbc7efdc2f5398.zip
2020/04/03, 02:34, v1.2.0
Diffstat (limited to 'node_modules/simple-concat/test/basic.js')
-rw-r--r--node_modules/simple-concat/test/basic.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/node_modules/simple-concat/test/basic.js b/node_modules/simple-concat/test/basic.js
new file mode 100644
index 0000000..f781294
--- /dev/null
+++ b/node_modules/simple-concat/test/basic.js
@@ -0,0 +1,41 @@
+var concat = require('../')
+var stream = require('stream')
+var test = require('tape')
+
+test('basic', function (t) {
+ t.plan(2)
+ var s = new stream.PassThrough()
+ concat(s, function (err, buf) {
+ t.error(err)
+ t.deepEqual(buf, new Buffer('abc123456789'))
+ })
+ s.write('abc')
+ setTimeout(function () {
+ s.write('123')
+ }, 10)
+ setTimeout(function () {
+ s.write('456')
+ }, 20)
+ setTimeout(function () {
+ s.end('789')
+ }, 30)
+})
+
+test('error', function (t) {
+ t.plan(2)
+ var s = new stream.PassThrough()
+ concat(s, function (err, buf) {
+ t.ok(err, 'got expected error')
+ t.ok(!buf)
+ })
+ s.write('abc')
+ setTimeout(function () {
+ s.write('123')
+ }, 10)
+ setTimeout(function () {
+ s.write('456')
+ }, 20)
+ setTimeout(function () {
+ s.emit('error', new Error('error'))
+ }, 30)
+})