From 50cb3b8872b5e317fcd44b3df2d63900779e34d0 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/course-outline/CourseOutline.test.jsx b/src/course-outline/CourseOutline.test.jsx index 2a0710c6be..7151ce4a9b 100644 --- a/src/course-outline/CourseOutline.test.jsx +++ b/src/course-outline/CourseOutline.test.jsx @@ -124,6 +124,9 @@ describe('', () => { it('adds new section correctly', async () => { const { findAllByTestId } = render(); let element = await findAllByTestId('section-card'); + window.HTMLElement.prototype.getBoundingClientRect = jest.fn(() => { + return { top: 0, bottom: 4000 }; + }); expect(element.length).toBe(4); axiosMock @@ -147,6 +150,9 @@ 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(() => { + return { top: 0, bottom: 4000 }; + }); axiosMock .onPost(getXBlockBaseApiUrl()) @@ -160,6 +166,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 +497,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 +518,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;