You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

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