@@ -65,16 +65,18 @@ describe('Hook extensions: deathChecker', function() {
65
65
native : function ( ) { }
66
66
} ;
67
67
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
+
69
71
var fail = function ( unfound , items ) {
70
72
console . log ( items ) ;
71
73
assert . fail ( undefined , unfound , "Value " + JSON . stringify ( unfound ) + " not found" ) ;
72
74
} ;
73
75
74
- var expectedDeaths = [ 'bar' , 'guard007' , 'builders' ] ;
76
+ var expectedDeaths = [ 'Foo' , ' bar', 'guard007' , 'builders' ] ;
75
77
var expectedBuffer = [
76
78
[ "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 ..." ] ,
78
80
[ "Hook deathChecker: Found dead creep guard007. Copying to queue..." ] ,
79
81
[ "Hook deathChecker: Found dead creep builders. Deleting..." ]
80
82
] ;
@@ -92,7 +94,12 @@ describe('Hook extensions: deathChecker', function() {
92
94
}
93
95
} , false ]
94
96
] ;
97
+ var expectedNotifications = [
98
+ [ "Found dead creep Foo without role. Deleting..." ]
99
+ ] ;
95
100
var buffer = [ ] ;
101
+ var calls = [ ] ;
102
+ var notifications = [ ] ;
96
103
97
104
hookDeathChecker . test . removeQueue = [ ] ;
98
105
lib . bufferConsole (
@@ -102,12 +109,18 @@ describe('Hook extensions: deathChecker', function() {
102
109
103
110
assert . deepEqual ( hookDeathChecker . test . removeQueue , expectedDeaths ) ;
104
111
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 ) ;
108
117
}
118
+
119
+ assert . strictEqual ( fn2 . callCount , expectedNotifications . length ) ;
120
+
109
121
eliminateDuplicates ( expectedCalls , calls , fail ) ;
110
122
eliminateDuplicates ( expectedBuffer , buffer , fail ) ;
123
+ eliminateDuplicates ( expectedNotifications , notifications , fail ) ;
111
124
112
125
assert . deepEqual ( expectedBuffer , [ ] ) ;
113
126
assert . deepEqual ( expectedCalls , [ ] ) ;
0 commit comments