Skip to content
This repository was archived by the owner on Sep 29, 2018. It is now read-only.

Commit 88cae85

Browse files
committed
Update tests for deathChecker
1 parent 7cbeeb9 commit 88cae85

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

test/extensions/tools/hooks/deathChecker.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,18 @@ describe('Hook extensions: deathChecker', function() {
6565
native: function() {}
6666
};
6767

68-
var fn = simple.mock(AI.extensions.commands.creepClone, 'native');
68+
var fn1 = simple.mock(AI.extensions.commands.creepClone, 'native');
69+
var fn2 = simple.mock(Game, 'notify');
70+
6971
var fail = function(unfound, items) {
7072
console.log(items);
7173
assert.fail(undefined, unfound, "Value " + JSON.stringify(unfound) + " not found");
7274
};
7375

74-
var expectedDeaths = ['bar', 'guard007', 'builders'];
76+
var expectedDeaths = ['Foo', 'bar', 'guard007', 'builders'];
7577
var expectedBuffer = [
7678
["Hook deathChecker: Found dead creep bar. Copying to priority queue..."],
77-
["Hook deathChecker: Found dead creep Foo. Dunno what to do..."],
79+
["Hook deathChecker: Found dead creep Foo. Deleting..."],
7880
["Hook deathChecker: Found dead creep guard007. Copying to queue..."],
7981
["Hook deathChecker: Found dead creep builders. Deleting..."]
8082
];
@@ -92,7 +94,12 @@ describe('Hook extensions: deathChecker', function() {
9294
}
9395
}, false]
9496
];
97+
var expectedNotifications = [
98+
["Found dead creep Foo without role. Deleting..."]
99+
];
95100
var buffer = [];
101+
var calls = [];
102+
var notifications = [];
96103

97104
hookDeathChecker.test.removeQueue = [];
98105
lib.bufferConsole(
@@ -102,12 +109,18 @@ describe('Hook extensions: deathChecker', function() {
102109

103110
assert.deepEqual(hookDeathChecker.test.removeQueue, expectedDeaths);
104111

105-
var calls = [];
106-
for (var i = 0; i < fn.calls.length; i++) {
107-
calls.push(fn.calls[i].args);
112+
for (var i = 0; i < fn1.calls.length; i++) {
113+
calls.push(fn1.calls[i].args);
114+
}
115+
for (var i = 0; i < fn2.calls.length; i++) {
116+
notifications.push(fn2.calls[i].args);
108117
}
118+
119+
assert.strictEqual(fn2.callCount, expectedNotifications.length);
120+
109121
eliminateDuplicates(expectedCalls, calls, fail);
110122
eliminateDuplicates(expectedBuffer, buffer, fail);
123+
eliminateDuplicates(expectedNotifications, notifications, fail);
111124

112125
assert.deepEqual(expectedBuffer, []);
113126
assert.deepEqual(expectedCalls, []);

0 commit comments

Comments
 (0)