Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

12345678910111213141516171819202122232425262728293031323334353637
  1. var test = require('tape');
  2. var resumer = require('../');
  3. var concat = require('concat-stream');
  4. test('implicit resume', function (t) {
  5. t.plan(1);
  6. var s = createStream();
  7. s.pipe(concat(function (err, body) {
  8. t.equal(body, 'beep boop\n');
  9. }));
  10. });
  11. test('pause/resume', function (t) {
  12. t.plan(2);
  13. var s = createStream();
  14. s.pause();
  15. var paused = true;
  16. setTimeout(function () {
  17. paused = false;
  18. s.resume();
  19. }, 100);
  20. s.pipe(concat(function (err, body) {
  21. t.equal(paused, false);
  22. t.equal(body, 'beep boop\n');
  23. }));
  24. });
  25. function createStream () {
  26. var stream = resumer();
  27. stream.queue('beep boop\n');
  28. stream.queue(null);
  29. return stream;
  30. }