UNPKG

1.15 kBJavaScriptView Raw
1var tape = require('tape')
2var through = require('through2')
3var stream = require('stream')
4var shift = require('./')
5
6tape('shifts next', function (t) {
7 var passthrough = through()
8
9 passthrough.write('hello')
10 passthrough.write('world')
11
12 t.same(shift(passthrough), Buffer('hello'))
13 t.same(shift(passthrough), Buffer('world'))
14 t.end()
15})
16
17tape('shifts next with core', function (t) {
18 var passthrough = stream.PassThrough()
19
20 passthrough.write('hello')
21 passthrough.write('world')
22
23 t.same(shift(passthrough), Buffer('hello'))
24 t.same(shift(passthrough), Buffer('world'))
25 t.end()
26})
27
28tape('shifts next with object mode', function (t) {
29 var passthrough = through({objectMode: true})
30
31 passthrough.write({hello: 1})
32 passthrough.write({world: 1})
33
34 t.same(shift(passthrough), {hello: 1})
35 t.same(shift(passthrough), {world: 1})
36 t.end()
37})
38
39tape('shifts next with object mode with core', function (t) {
40 var passthrough = stream.PassThrough({objectMode: true})
41
42 passthrough.write({hello: 1})
43 passthrough.write({world: 1})
44
45 t.same(shift(passthrough), {hello: 1})
46 t.same(shift(passthrough), {world: 1})
47 t.end()
48})