From a68964ad02c32a7b43b4e97bbe12d89b8c2dbc7c Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Wed, 13 Dec 2023 18:09:24 +0530 Subject: [PATCH] test: update tests --- src/course-outline/CourseOutline.test.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/course-outline/CourseOutline.test.jsx b/src/course-outline/CourseOutline.test.jsx index 2a0710c6be..eac6fa5c84 100644 --- a/src/course-outline/CourseOutline.test.jsx +++ b/src/course-outline/CourseOutline.test.jsx @@ -124,6 +124,10 @@ describe('', () => { it('adds new section correctly', async () => { const { findAllByTestId } = render(); let element = await findAllByTestId('section-card'); + window.HTMLElement.prototype.getBoundingClientRect = jest.fn(() => ({ + top: 0, + bottom: 4000, + })); expect(element.length).toBe(4); axiosMock @@ -147,6 +151,10 @@ describe('', () => { const [section] = await findAllByTestId('section-card'); let subsections = await within(section).findAllByTestId('subsection-card'); expect(subsections.length).toBe(1); + window.HTMLElement.prototype.getBoundingClientRect = jest.fn(() => ({ + top: 0, + bottom: 4000, + })); axiosMock .onPost(getXBlockBaseApiUrl()) @@ -160,6 +168,7 @@ describe('', () => { subsections = await within(section).findAllByTestId('subsection-card'); expect(subsections.length).toBe(2); + expect(window.HTMLElement.prototype.scrollIntoView).toBeCalled(); }); it('render error alert after failed reindex correctly', async () => { @@ -490,7 +499,7 @@ describe('', () => { expect(getByRole('button', { name: '5 Section highlights' })).toBeInTheDocument(); }); - it('check section order list when set section order query is successful', async () => { + it('check section list is ordered successfully', async () => { const { getAllByTestId } = render(); const courseBlockId = courseOutlineIndexMock.courseStructure.id; let { children } = courseOutlineIndexMock.courseStructure.childInfo; @@ -511,7 +520,7 @@ describe('', () => { }); }); - it('check section order list when set section order query is unsuccessful', async () => { + it('check section list is restored to original order when API call fails', async () => { const { getAllByTestId } = render(); const courseBlockId = courseOutlineIndexMock.courseStructure.id; const { children } = courseOutlineIndexMock.courseStructure.childInfo;