File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,28 @@ beforeEach(function(){
90
90
return "Expected " + expected + " to match an Error with message " + toJson ( messageRegexp ) ;
91
91
} ;
92
92
return this . actual . name == 'Error' && messageRegexp . test ( this . actual . message ) ;
93
+ } ,
94
+
95
+ toHaveBeenCalledOnce : function ( ) {
96
+ if ( arguments . length > 0 ) {
97
+ throw new Error ( 'toHaveBeenCalledOnce does not take arguments, use toHaveBeenCalledWith' ) ;
98
+ }
99
+
100
+ if ( ! jasmine . isSpy ( this . actual ) ) {
101
+ throw new Error ( 'Expected a spy, but got ' + jasmine . pp ( this . actual ) + '.' ) ;
102
+ }
103
+
104
+ this . message = function ( ) {
105
+ var msg = 'Expected spy ' + this . actual . identity + ' to have been called once, but was ' ,
106
+ count = this . actual . callCount ;
107
+ return [
108
+ count == 0 ? msg + 'never called.'
109
+ : msg + 'called ' + count + ' times.' ,
110
+ msg . replace ( 'to have' , 'not to have' ) + 'called once.'
111
+ ] ;
112
+ } ;
113
+
114
+ return this . actual . callCount == 1 ;
93
115
}
94
116
} ) ;
95
117
You can’t perform that action at this time.
0 commit comments