event.mocha.js 520 B

12345678910111213141516171819202122232425
  1. const tx2 = require('..')
  2. const should = require('should')
  3. describe('Event', function() {
  4. it('should emit an event without data', (done) => {
  5. tx2.once('data', (dt) => {
  6. should(dt.type).eql('human:event')
  7. done()
  8. })
  9. tx2.event('something special')
  10. })
  11. it('should emit an event with data', (done) => {
  12. tx2.once('data', (dt) => {
  13. should(dt.type).eql('human:event')
  14. should(dt.data.yes).eql(true)
  15. done()
  16. })
  17. tx2.event('something special', { yes : true })
  18. })
  19. })