This repository was archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchannel.js
81 lines (73 loc) · 1.9 KB
/
channel.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var channel = require("../lib/abaaso.js").channel;
exports["put_success"] = {
setUp: function (done) {
this.chan = channel();
done();
},
test: function (test) {
var self = this;
test.expect(4);
test.equal(this.chan.queue.length, 0, "Should be '0'");
this.chan.put(true).then(function (arg) {
test.equal(arg[0], "continue", "Should be 'continue'");
test.equal(arg[1], null, "Should be 'null'");
test.equal(self.chan.queue.length, 1, "Should be '1'");
test.done();
});
}
};
exports["put_failure"] = {
setUp: function (done) {
this.chan = channel();
this.chan.put(false).then(function () {
done();
});
},
test: function (test) {
var self = this;
test.expect(4);
test.equal(this.chan.queue.length, 1, "Should be '1'");
this.chan.put(true).then(function (arg) {
test.equal(arg[0], "pause", "Should be 'pause'");
test.equal(arg[1], null, "Should be 'null'");
test.equal(self.chan.queue.length, 1, "Should be '1'");
test.done();
});
}
};
exports["take_success"] = {
setUp: function (done) {
this.chan = channel();
this.chan.put(false).then(function () {
done();
});
},
test: function (test) {
var self = this;
test.expect(4);
test.equal(this.chan.queue.length, 1, "Should be '1'");
this.chan.take().then(function (arg) {
test.equal(arg[0], "continue", "Should be 'continue'");
test.equal(arg[1], false, "Should be 'false'");
test.equal(self.chan.queue.length, 0, "Should be '0'");
test.done();
});
}
};
exports["take_failure"] = {
setUp: function (done) {
this.chan = channel();
done();
},
test: function (test) {
var self = this;
test.expect(4);
test.equal(this.chan.queue.length, 0, "Should be '0'");
this.chan.take().then(function (arg) {
test.equal(arg[0], "pause", "Should be 'pause'");
test.equal(arg[1], null, "Should be 'null'");
test.equal(self.chan.queue.length, 0, "Should be '0'");
test.done();
});
}
};