UNPKG

1.44 kBJavaScriptView Raw
1
2
3var pull = require('pull-stream')
4var cat = require('../')
5var test = require('tape')
6
7test('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
21test('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
35test('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
53test('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
65test('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})