Skip to content

Commit 0631817

Browse files
committed
Fixing tests to ignore updatedModels being sent in Ajax calls
1 parent cf04223 commit 0631817

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/LiveComponent/assets/test/tools.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,19 @@ class MockedAjaxCall {
240240
const params = new URLSearchParams({
241241
data: JSON.stringify(this.expectedSentData)
242242
});
243-
matcherObject.url = `end:?${params.toString()}`;
243+
matcherObject.functionMatcher = (url: string) => {
244+
return url.includes(`?${params.toString()}`);
245+
};
244246
} else {
245-
matcherObject.body = this.getRequestBody();
247+
// match the body, by without "updatedModels" which is not important
248+
// and also difficult/tedious to always assert
249+
matcherObject.functionMatcher = (url: string, request: any) => {
250+
const body = JSON.parse(request.body);
251+
delete body.updatedModels;
252+
253+
return JSON.stringify(body) === JSON.stringify(this.getRequestBody());
254+
};
255+
246256
if (this.expectedActions.length === 1) {
247257
matcherObject.url = `end:/${this.expectedActions[0].name}`;
248258
} else if (this.expectedActions.length > 1) {

0 commit comments

Comments
 (0)