UNPKG

1.13 kBJavaScriptView Raw
1
2
3var pull = require('pull-stream')
4var cat = require('../')
5var test = require('tape')
6
7test('cat', function (t) {
8
9 cat([pull.values([1,2,3]), pull.values([4,5,6])])
10 .pipe(pull.collect(function (err, ary) {
11 console.log(err, ary)
12 t.notOk(err)
13 t.deepEqual(ary, [1,2,3,4,5,6])
14 t.end()
15 }))
16
17})
18
19test('cat - with empty', function (t) {
20
21 cat([pull.values([1,2,3]), null, pull.values([4,5,6])])
22 .pipe(pull.collect(function (err, ary) {
23 console.log(err, ary)
24 t.notOk(err)
25 t.deepEqual(ary, [1,2,3,4,5,6])
26 t.end()
27 }))
28
29})
30
31test('cat - with empty stream', function (t) {
32 var ended = false
33 var justEnd = function (err, cb) { ended = true; cb(true) }
34 cat([pull.values([1,2,3]), justEnd, pull.values([4,5,6])])
35 .pipe(pull.collect(function (err, ary) {
36 console.log(err, ary)
37 t.ok(ended)
38 t.notOk(err)
39 t.deepEqual(ary, [1,2,3,4,5,6])
40 t.end()
41 }))
42})
43
44
45
46test('abort - with empty', function (t) {
47
48 cat([pull.values([1,2,3]), null, pull.values([4,5,6])])
49 .pipe(function (read) {
50 read(true, function (err) {
51 t.equal(err, true)
52 t.end()
53 })
54 })
55
56})
57