-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed.test.js
109 lines (107 loc) · 2.98 KB
/
feed.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var feedlib = require("./feed.js");
test("feed filtered by parent", () =>{
var dummyMessage = {
"author":
{
"message":function (message){} ,
"send":function (message){}
}
}
var gameState = {
"population": {
"p1":{
"name": "p1",
"gender": "male",
"activity": "gather",
"food":20,
"grain":10
},
"p2":{
"name": "p2",
"gender": "female",
"grain":10
}},
"children":{
"C1": {
"mother": "p2",
"father": "p1",
"age": 4,
"food": 0,
"gender": "female",
"name": "C1"
},
"C2": {
"mother": "p2",
"father": "p1",
"age": 1,
"food": 0,
"gender": "female",
"name": "C2"
},
"C3": {
"mother": "p4",
"father": "p5",
"age": 1,
"food": 0,
"gender": "female",
"name": "C3"
}
}
}
//module.exports.feed = ( msg, player, amount, childList, gameState) =>{
response = feedlib.feed(dummyMessage, gameState.population.p1, 2, ["p2"], gameState)
expect(response).toBe("p1 feeds 2 to C1\np1 feeds 2 to C2\n")
});
test("feed !all", () =>{
var dummyMessage = {
"author":
{
"message":function (message){} ,
"send":function (message){}
}
}
var gameState = {
"population": {
"p1":{
"name": "p1",
"gender": "male",
"activity": "gather",
"food":20,
"grain":10
},
"p2":{
"name": "p2",
"gender": "female",
"grain":10
}},
"children":{
"C1": {
"mother": "p2",
"father": "p1",
"age": 4,
"food": 0,
"gender": "female",
"name": "C1"
},
"C2": {
"mother": "p2",
"father": "p1",
"age": 1,
"food": 0,
"gender": "female",
"name": "C2"
},
"C3": {
"mother": "p4",
"father": "p5",
"age": 1,
"food": 0,
"gender": "female",
"name": "C3"
}
}
}
//module.exports.feed = ( msg, player, amount, childList, gameState) =>{
response = feedlib.feed(dummyMessage, gameState.population.p1, 2, ["!all"], gameState)
expect(response).toBe("p1 feeds 2 to C1\np1 feeds 2 to C2\np1 feeds 2 to C3\n")
});