Skip to content

Commit 1140b3b

Browse files
author
Matt Mazzola
committed
Restore expect's in tests on pages which uses workaround to compare pages without using jasmine equals which causes recursive loop
1 parent ef78173 commit 1140b3b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/test.spec.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,6 +3535,7 @@ describe('SDK-to-MockApp', function () {
35353535
}
35363536
}
35373537
};
3538+
const testDataHandler: jasmine.Spy = testData.handler;
35383539

35393540
report.on(testData.eventName, testData.handler);
35403541

@@ -3543,7 +3544,9 @@ describe('SDK-to-MockApp', function () {
35433544
.then(response => {
35443545
// Assert
35453546
expect(testData.handler).toHaveBeenCalledWith(jasmine.any(CustomEvent));
3546-
// expect(testData.handler).toHaveBeenCalledWith(jasmine.objectContaining(testData.expectedEvent));
3547+
// Workaround to compare pages which prevents recursive loop in jasmine equals
3548+
// expect(testData.handler2).toHaveBeenCalledWith(jasmine.objectContaining({ detail: testData.simulatedPageChangeBody }));
3549+
expect(testData.handler.calls.mostRecent().args[0].detail.newPage.name).toEqual(testData.expectedEvent.detail.newPage.name);
35473550
done();
35483551
});
35493552
});
@@ -3552,12 +3555,12 @@ describe('SDK-to-MockApp', function () {
35523555
// Arrange
35533556
const testData = {
35543557
reportId: 'fakeReportId',
3555-
eventName: 'filtersApplied',
3558+
eventName: 'pageChanged',
35563559
handler: jasmine.createSpy('handler'),
35573560
handler2: jasmine.createSpy('handler2'),
35583561
simulatedPageChangeBody: {
35593562
initiator: 'sdk',
3560-
page: {
3563+
newPage: {
35613564
name: 'page1',
35623565
displayName: 'Page 1'
35633566
}
@@ -3572,7 +3575,9 @@ describe('SDK-to-MockApp', function () {
35723575
.then(response => {
35733576
// Assert
35743577
expect(testData.handler2).toHaveBeenCalledWith(jasmine.any(CustomEvent));
3575-
// expect(testData.handler2).toHaveBeenCalledWith(jasmine.objectContaining({ detail: testData.simulatedPageChangeBody }));
3578+
// Workaround to compare pages which prevents recursive loop in jasmine equals
3579+
// expect(testData.handler).toHaveBeenCalledWith(jasmine.objectContaining(testData.expectedEvent));
3580+
expect(testData.handler2.calls.mostRecent().args[0].detail.newPage.name).toEqual(testData.simulatedPageChangeBody.newPage.name);
35763581
expect(testData.handler).not.toHaveBeenCalled();
35773582
done();
35783583
});

0 commit comments

Comments
 (0)