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 | pull(
|
10 | cat([pull.values([1,2,3]), pull.values([4,5,6])]),
|
11 | pull.collect(function (err, ary) {
|
12 | console.log(err, ary)
|
13 | t.notOk(err)
|
14 | t.deepEqual(ary, [1,2,3,4,5,6])
|
15 | t.end()
|
16 | })
|
17 | )
|
18 |
|
19 | })
|
20 |
|
21 | test('cat - with empty', function (t) {
|
22 |
|
23 | pull(
|
24 | cat([pull.values([1,2,3]), null, pull.values([4,5,6])]),
|
25 | pull.collect(function (err, ary) {
|
26 | console.log(err, ary)
|
27 | t.notOk(err)
|
28 | t.deepEqual(ary, [1,2,3,4,5,6])
|
29 | t.end()
|
30 | })
|
31 | )
|
32 |
|
33 | })
|
34 |
|
35 | test('cat - with empty stream', function (t) {
|
36 | var ended = false
|
37 | var justEnd = function (err, cb) { ended = true; cb(true) }
|
38 |
|
39 | pull(
|
40 | cat([pull.values([1,2,3]), justEnd, pull.values([4,5,6])]),
|
41 | pull.collect(function (err, ary) {
|
42 | console.log(err, ary)
|
43 | t.ok(ended)
|
44 | t.notOk(err)
|
45 | t.deepEqual(ary, [1,2,3,4,5,6])
|
46 | t.end()
|
47 | })
|
48 | )
|
49 | })
|
50 |
|
51 |
|
52 |
|
53 | test('abort - with empty', function (t) {
|
54 | pull(
|
55 | cat([pull.values([1,2,3]), null, pull.values([4,5,6])]),
|
56 | function (read) {
|
57 | read(true, function (err) {
|
58 | t.equal(err, true)
|
59 | t.end()
|
60 | })
|
61 | }
|
62 | )
|
63 | })
|
64 |
|
65 | test('error', function (t) {
|
66 | var err = new Error('test error')
|
67 | pull(
|
68 | cat([pull.values([1,2,3]), function (_, cb) {
|
69 | cb(err)
|
70 | }]),
|
71 | pull.collect(function (_err) {
|
72 | t.equal(_err, err)
|
73 | t.end()
|
74 | })
|
75 | )
|
76 | })
|