Front end of the Slack clone application.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var test = require('tape')
  2. var through = require('../')
  3. // must emit end before close.
  4. test('end before close', function (assert) {
  5. var ts = through()
  6. var ended = false, closed = false
  7. ts.on('end', function () {
  8. assert.ok(!closed)
  9. ended = true
  10. })
  11. ts.on('close', function () {
  12. assert.ok(ended)
  13. closed = true
  14. })
  15. ts.write(1)
  16. ts.write(2)
  17. ts.write(3)
  18. ts.end()
  19. assert.ok(ended)
  20. assert.ok(closed)
  21. assert.end()
  22. })
  23. test('end only once', function (t) {
  24. var ts = through()
  25. var ended = false, closed = false
  26. ts.on('end', function () {
  27. t.equal(ended, false)
  28. ended = true
  29. })
  30. ts.queue(null)
  31. ts.queue(null)
  32. ts.queue(null)
  33. ts.resume()
  34. t.end()
  35. })