Front end of the Slack clone application.

12345678910111213141516171819202122232425262728293031
  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. ts.autoDestroy = false
  7. var ended = false, closed = false
  8. ts.on('end', function () {
  9. assert.ok(!closed)
  10. ended = true
  11. })
  12. ts.on('close', function () {
  13. assert.ok(ended)
  14. closed = true
  15. })
  16. ts.write(1)
  17. ts.write(2)
  18. ts.write(3)
  19. ts.end()
  20. assert.ok(ended)
  21. assert.notOk(closed)
  22. ts.destroy()
  23. assert.ok(closed)
  24. assert.end()
  25. })