post.test.js 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var assert = require('assert');
  2. var Kareem = require('../');
  3. describe('execPost', function() {
  4. var hooks;
  5. beforeEach(function() {
  6. hooks = new Kareem();
  7. });
  8. it('handles errors', function(done) {
  9. hooks.post('cook', function(eggs, callback) {
  10. callback('error!');
  11. });
  12. hooks.execPost('cook', null, [4], function(error, eggs) {
  13. assert.equal('error!', error);
  14. assert.ok(!eggs);
  15. done();
  16. });
  17. });
  18. it('multiple posts', function(done) {
  19. hooks.post('cook', function(eggs, callback) {
  20. setTimeout(
  21. function() {
  22. callback();
  23. },
  24. 5);
  25. });
  26. hooks.post('cook', function(eggs, callback) {
  27. setTimeout(
  28. function() {
  29. callback();
  30. },
  31. 5);
  32. });
  33. hooks.execPost('cook', null, [4], function(error, eggs) {
  34. assert.ifError(error);
  35. assert.equal(4, eggs);
  36. done();
  37. });
  38. });
  39. });