@@ -2,7 +2,7 @@ const assert = require('assert')
22
33let registry = new Set ( )
44
5- const getCallLine = ( ) => ( new Error ( ) ) . stack . split ( '\n' ) [ 4 ]
5+ const getCallLines = ( ) => ( new Error ( ) ) . stack . split ( '\n' ) . slice ( 4 ) . join ( '\n' )
66
77/**
88 * A hack to capture a reference to the `equals` jasmineUtil
@@ -73,7 +73,7 @@ class WhenMock {
7373 // * `once` mocks are used prioritized
7474 this . callMocks = this . callMocks
7575 . filter ( ( callMock ) => once || callMock . once || ! equals ( callMock . matchers , matchers ) )
76- . concat ( { matchers, mockImplementation, expectCall, once, called : false , id : this . nextCallMockId , callLine : getCallLine ( ) } )
76+ . concat ( { matchers, mockImplementation, expectCall, once, called : false , id : this . nextCallMockId , callLines : getCallLines ( ) } )
7777 . sort ( ( a , b ) => {
7878 // Once mocks should appear before the rest
7979 if ( a . once !== b . once ) {
@@ -95,12 +95,12 @@ class WhenMock {
9595 let isMatch = false
9696
9797 if ( matchers && matchers [ 0 ] &&
98- // is a possible all args matcher object
99- ( typeof matchers [ 0 ] === 'function' || typeof matchers [ 0 ] === 'object' ) &&
100- // ensure not a proxy
101- '_isAllArgsFunctionMatcher' in matchers [ 0 ] &&
102- // check for the special property name
103- matchers [ 0 ] . _isAllArgsFunctionMatcher === true
98+ // is a possible all args matcher object
99+ ( typeof matchers [ 0 ] === 'function' || typeof matchers [ 0 ] === 'object' ) &&
100+ // ensure not a proxy
101+ '_isAllArgsFunctionMatcher' in matchers [ 0 ] &&
102+ // check for the special property name
103+ matchers [ 0 ] . _isAllArgsFunctionMatcher === true
104104 ) {
105105 if ( matchers . length > 1 ) throw new Error ( 'When using when.allArgs, it must be the one and only matcher provided to calledWith. You have incorrectly provided other matchers along with when.allArgs.' )
106106 isMatch = checkArgumentMatchers ( expectCall , [ args ] ) ( true , matchers [ 0 ] , 0 )
@@ -224,11 +224,11 @@ const verifyAllWhenMocksCalled = () => {
224224 } , [ [ ] , [ ] , [ ] ] )
225225
226226 const callLines = uncalledMocks
227- . filter ( m => Boolean ( m . callLine ) )
228- . map ( m => `\n ${ String ( m . callLine ) . trim ( ) } ` )
227+ . filter ( m => Boolean ( m . callLines ) )
228+ . map ( m => `\n ${ String ( m . callLines ) . trim ( ) } ` )
229229 . join ( '' )
230230
231- const msg = `Failed verifyAllWhenMocksCalled: ${ uncalledMocks . length } not called at: ${ callLines } \n\n\n...rest of the stack...`
231+ const msg = `Failed verifyAllWhenMocksCalled: ${ uncalledMocks . length } not called: ${ callLines } \n\n\n...rest of the stack...`
232232
233233 assert . equal ( `called mocks: ${ calledMocks . length } ` , `called mocks: ${ allMocks . length } ` , msg )
234234}
0 commit comments