-
Notifications
You must be signed in to change notification settings - Fork 8
/
post.test.js
46 lines (39 loc) · 923 Bytes
/
post.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var assert = require('assert');
var Kareem = require('../');
describe('execPost', function() {
var hooks;
beforeEach(function() {
hooks = new Kareem();
});
it('handles errors', function(done) {
hooks.post('cook', function(eggs, callback) {
callback('error!');
});
hooks.execPost('cook', null, [4], function(error, eggs) {
assert.equal('error!', error);
assert.ok(!eggs);
done();
});
});
it('multiple posts', function(done) {
hooks.post('cook', function(eggs, callback) {
setTimeout(
function() {
callback();
},
5);
});
hooks.post('cook', function(eggs, callback) {
setTimeout(
function() {
callback();
},
5);
});
hooks.execPost('cook', null, [4], function(error, eggs) {
assert.ifError(error);
assert.equal(4, eggs);
done();
});
});
});