errors.js 835 B

1234567891011121314151617181920212223242526272829303132333435
  1. var test = require('tap').test,
  2. eventify = require('..');
  3. test('Eventify protects your object', function(t) {
  4. t.plan(1);
  5. try {
  6. eventify({
  7. on: "I'm a dummy string, please don't wipe me out"
  8. });
  9. } catch (e) {
  10. t.ok(true, 'Eventify should thrown an exception to protect your object');
  11. }
  12. t.end();
  13. });
  14. test('Eventify does not allow falsy objects', function(t) {
  15. t.plan(1);
  16. try {
  17. eventify(false);
  18. } catch (e) {
  19. t.ok(true, 'Eventify should thrown an exception to protect your object');
  20. }
  21. t.end();
  22. });
  23. test('Eventify does not allow to subscribe without function', function(t) {
  24. t.plan(1);
  25. var subject = eventify({});
  26. try {
  27. subject.on('foo')
  28. } catch (e) {
  29. t.ok(true, 'Eventify should thrown an exception: no function is specified');
  30. }
  31. t.end();
  32. });