File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,28 @@ beforeEach(function(){
9090 return "Expected " + expected + " to match an Error with message " + toJson ( messageRegexp ) ;
9191 } ;
9292 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 ;
93115 }
94116 } ) ;
95117
You can’t perform that action at this time.
0 commit comments