@@ -38,7 +38,7 @@ export function shutdownTest() {
3838 requestInfo . push ( ` HEADERS: ${ JSON . stringify ( unmatchedFetchError . headers ) } ` ) ;
3939 requestInfo . push ( ` DATA: ${ unmatchedFetchError . method === 'GET' ? urlParams . get ( 'data' ) : unmatchedFetchError . body } ` ) ;
4040
41- console . log ( ` UNMATCHED request was made with the following info:` , "\n" , requestInfo . join ( "\n" ) ) ;
41+ console . log ( ' UNMATCHED request was made with the following info:' , '\n' , requestInfo . join ( '\n' ) ) ;
4242 } ) ;
4343 unmatchedFetchErrors = [ ] ;
4444
@@ -118,6 +118,7 @@ class MockedAjaxCall {
118118 private expectedSentData ?: any ;
119119 private expectedActions : Array < { name : string , args : any } > = [ ] ;
120120 private expectedHeaders : any = { } ;
121+ private expectedChildFingerprints : any = null ;
121122 private changeDataCallback ?: ( data : any ) => void ;
122123 private template ?: ( data : any ) => string
123124 options : any = { } ;
@@ -142,6 +143,14 @@ class MockedAjaxCall {
142143 return this ;
143144 }
144145
146+ expectChildFingerprints = ( fingerprints : any ) : MockedAjaxCall => {
147+ this . checkInitialization ( 'expectSentData' ) ;
148+
149+ this . expectedChildFingerprints = fingerprints ;
150+
151+ return this ;
152+ }
153+
145154 /**
146155 * Call if the "server" will change the data before it re-renders
147156 */
@@ -245,15 +254,20 @@ class MockedAjaxCall {
245254 } else {
246255 requestInfo . push ( ` DATA: ${ JSON . stringify ( this . getRequestBody ( ) ) } ` ) ;
247256 }
257+
258+ if ( this . expectedChildFingerprints ) {
259+ requestInfo . push ( ` CHILD FINGERPRINTS: ${ JSON . stringify ( this . expectedChildFingerprints ) } ` )
260+ }
261+
248262 if ( this . expectedActions . length === 1 ) {
249263 requestInfo . push ( ` Expected URL to contain action /${ this . expectedActions [ 0 ] . name } ` )
250264 }
251265
252- return requestInfo . join ( "\n" ) ;
266+ return requestInfo . join ( '\n' ) ;
253267 }
254268
255269 // https://www.wheresrhys.co.uk/fetch-mock/#api-mockingmock_matcher
256- private getMockMatcher ( forError = false ) : any {
270+ private getMockMatcher ( createMatchForShowingError = false ) : any {
257271 if ( ! this . expectedSentData ) {
258272 throw new Error ( 'expectedSentData not set yet' ) ;
259273 }
@@ -265,15 +279,23 @@ class MockedAjaxCall {
265279 }
266280
267281 if ( this . method === 'GET' ) {
268- const params = new URLSearchParams ( {
282+ const paramsData : any = {
269283 data : JSON . stringify ( this . expectedSentData )
270- } ) ;
271- if ( forError ) {
284+ } ;
285+ if ( this . expectedChildFingerprints ) {
286+ paramsData . childrenFingerprints = JSON . stringify ( this . expectedChildFingerprints ) ;
287+ }
288+ const params = new URLSearchParams ( paramsData ) ;
289+ if ( createMatchForShowingError ) {
272290 // simplified version for error reporting
273291 matcherObject . url = `?${ params . toString ( ) } ` ;
274292 } else {
275293 matcherObject . functionMatcher = ( url : string ) => {
276- return url . includes ( `?${ params . toString ( ) } ` ) ;
294+ const actualUrl = new URL ( url ) ;
295+ const actualParams = new URLSearchParams ( actualUrl . search ) ;
296+ actualParams . delete ( 'updatedModels' ) ;
297+
298+ return actualParams . toString ( ) === params . toString ( ) ;
277299 } ;
278300 }
279301 } else {
@@ -289,7 +311,7 @@ class MockedAjaxCall {
289311 if ( this . expectedActions . length === 1 ) {
290312 matcherObject . url = `end:/${ this . expectedActions [ 0 ] . name } ` ;
291313 } else if ( this . expectedActions . length > 1 ) {
292- matcherObject . url = ` end:/_batch` ;
314+ matcherObject . url = ' end:/_batch' ;
293315 }
294316 }
295317
@@ -308,6 +330,10 @@ class MockedAjaxCall {
308330 data : this . expectedSentData
309331 } ;
310332
333+ if ( this . expectedChildFingerprints ) {
334+ body . childrenFingerprints = this . expectedChildFingerprints ;
335+ }
336+
311337 if ( this . expectedActions . length === 1 ) {
312338 body . args = this . expectedActions [ 0 ] . args ;
313339 } else if ( this . expectedActions . length > 1 ) {
0 commit comments