1 |
|
2 |
|
3 | var pull = require('pull-stream')
|
4 | var cat = require('../')
|
5 | var test = require('tape')
|
6 |
|
7 | test('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 |
|
19 | test('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 |
|
31 | test('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 |
|
46 | test('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 |
|