2.js 1023 B

1234567891011121314151617181920212223242526272829303132333435
  1. var test = require('tape')
  2. , streamify = require('..')
  3. , concat = require('concat-stream')
  4. ;
  5. test('empty array', function(t) {
  6. var s = streamify([]);
  7. s.pipe(concat({encoding: 'object'}, function(res) {
  8. t.equal(1, arguments.length, 'concat returns 1 arg');
  9. t.equal(0, res.length, 'result is an empty list');
  10. t.deepEqual([], res, 'result matches expectation');
  11. t.end();
  12. }));
  13. });
  14. test('array of strings', function(t) {
  15. var s = streamify(['1', '2', '3', 'Four']);
  16. s.pipe(concat(function(res) {
  17. t.equal(1, arguments.length, 'concat returns 1 arg');
  18. t.equal('123Four', res.toString(), 'result matches expectation');
  19. t.end();
  20. }));
  21. });
  22. test('array of buffers', function(t) {
  23. var s = streamify([new Buffer('One'), new Buffer('Two')]);
  24. s.pipe(concat(function(res) {
  25. t.equal(1, arguments.length, 'concat returns 1 arg');
  26. t.equal('OneTwo', res.toString(), 'result matches expectation');
  27. t.end();
  28. }));
  29. });