/
base-test.js
62 lines (61 loc) · 1.5 KB
/
base-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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
assert = require('assert')
RedisBase = require("../lib/redis-mq/RedisBase").RedisBase
RedisHelper = require("../lib/redis-mq/RedisBase").RedisHelper
var options = {
delimiter: {test: "a"},
client: {test: "b"},
redis_base: {test: "c"},
id: {test: "d"}
}
exports.options = options;
exports.build_test = function(constructor){
return {
"Testing Constructor": {
topic: function() {
return new (constructor)(options);
},
"The delimiter saved": function(base) {
assert.equal("a", base.delimiter.test);
},
"The client saved": function(base) {
assert.equal("b", base.client.test);
},
"The base saved": function(base) {
assert.equal("c", base.redis_base.test);
},
"The id saved": function(base) {
assert.equal("d", base.id.test);
},
"Exception Thrown": function(base) {
assert.throws(function() {new (constructor)()}, "No value found for required key client in RedisBase.");
}
},
"Testing onDone": {
topic: function() {
base = new (constructor)(options);
base.onDone(function() {
return 5;
});
return base.listener();
},
'The function should have ran': function(topic) {
assert.equal(5, topic);
}
},
"Testing build key": {
topic: function() {
var options = {
delimiter: "::",
client: {},
redis_base: "basebase",
id: 54321
}
base = new (constructor)(options);
return base.buildKey("thiskey");
},
"Got a key": function(topic) {
assert.equal("basebase::54321::thiskey", topic);
}
}
}
}