Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Dec 13, 2023
1 parent 296c045 commit a68964a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/course-outline/CourseOutline.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ describe('<CourseOutline />', () => {
it('adds new section correctly', async () => {
const { findAllByTestId } = render(<RootWrapper />);
let element = await findAllByTestId('section-card');
window.HTMLElement.prototype.getBoundingClientRect = jest.fn(() => ({
top: 0,
bottom: 4000,
}));
expect(element.length).toBe(4);

axiosMock
Expand All @@ -147,6 +151,10 @@ describe('<CourseOutline />', () => {
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())
Expand All @@ -160,6 +168,7 @@ describe('<CourseOutline />', () => {

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 () => {
Expand Down Expand Up @@ -490,7 +499,7 @@ describe('<CourseOutline />', () => {
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(<RootWrapper />);
const courseBlockId = courseOutlineIndexMock.courseStructure.id;
let { children } = courseOutlineIndexMock.courseStructure.childInfo;
Expand All @@ -511,7 +520,7 @@ describe('<CourseOutline />', () => {
});
});

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(<RootWrapper />);
const courseBlockId = courseOutlineIndexMock.courseStructure.id;
const { children } = courseOutlineIndexMock.courseStructure.childInfo;
Expand Down

0 comments on commit a68964a

Please sign in to comment.