summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/mississippi/node_modules/duplexify/node_modules/stream-shift/test.js
blob: c0222c37d53fe542491c5c10dba71ab97b964a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var tape = require('tape')
var through = require('through2')
var stream = require('stream')
var shift = require('./')

tape('shifts next', function (t) {
  var passthrough = through()

  passthrough.write('hello')
  passthrough.write('world')

  t.same(shift(passthrough), Buffer('hello'))
  t.same(shift(passthrough), Buffer('world'))
  t.end()
})

tape('shifts next with core', function (t) {
  var passthrough = stream.PassThrough()

  passthrough.write('hello')
  passthrough.write('world')

  t.same(shift(passthrough), Buffer('hello'))
  t.same(shift(passthrough), Buffer('world'))
  t.end()
})

tape('shifts next with object mode', function (t) {
  var passthrough = through({objectMode: true})

  passthrough.write({hello: 1})
  passthrough.write({world: 1})

  t.same(shift(passthrough), {hello: 1})
  t.same(shift(passthrough), {world: 1})
  t.end()
})

tape('shifts next with object mode with core', function (t) {
  var passthrough = stream.PassThrough({objectMode: true})

  passthrough.write({hello: 1})
  passthrough.write({world: 1})

  t.same(shift(passthrough), {hello: 1})
  t.same(shift(passthrough), {world: 1})
  t.end()
})