[TNL-7268] Add high priority tests
This commit is contained in:
@@ -2,7 +2,9 @@ import React from 'react';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { fireEvent } from '@testing-library/dom';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import {
|
||||
initialState, render, screen, testUnits,
|
||||
} from '../../../../setupTest';
|
||||
import SequenceNavigation from './SequenceNavigation';
|
||||
import useIndexOfLastVisibleChild from '../../../../tabs/useIndexOfLastVisibleChild';
|
||||
|
||||
@@ -11,46 +13,6 @@ jest.mock('../../../../tabs/useIndexOfLastVisibleChild');
|
||||
useIndexOfLastVisibleChild.mockReturnValue([0, null, null]);
|
||||
|
||||
describe('Sequence Navigation', () => {
|
||||
const testUnits = [...Array(10).keys()].map(i => String(i + 1));
|
||||
const initialState = {
|
||||
courseware: {
|
||||
sequenceStatus: 'loaded',
|
||||
courseStatus: 'loaded',
|
||||
courseId: '1',
|
||||
},
|
||||
models: {
|
||||
courses: {
|
||||
1: {
|
||||
sectionIds: ['1'],
|
||||
},
|
||||
},
|
||||
sections: {
|
||||
1: {
|
||||
sequenceIds: ['1', '2'],
|
||||
},
|
||||
},
|
||||
sequences: {
|
||||
1: {
|
||||
unitIds: testUnits,
|
||||
showCompletion: true,
|
||||
},
|
||||
2: {
|
||||
unitIds: testUnits,
|
||||
showCompletion: true,
|
||||
},
|
||||
},
|
||||
units: testUnits.reduce(
|
||||
(acc, unitId) => Object.assign(acc, {
|
||||
[unitId]: {
|
||||
contentType: 'other',
|
||||
title: unitId,
|
||||
},
|
||||
}),
|
||||
{},
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
const mockData = {
|
||||
previousSequenceHandler: () => {},
|
||||
onNavigate: () => {},
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
import React from 'react';
|
||||
import { fireEvent } from '@testing-library/dom';
|
||||
import SequenceNavigationDropdown from './SequenceNavigationDropdown';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import {
|
||||
initialState, render, screen, testUnits,
|
||||
} from '../../../../setupTest';
|
||||
|
||||
describe('Sequence Navigation Dropdown', () => {
|
||||
const testUnits = ['1', '2', '3'];
|
||||
|
||||
const initialState = {
|
||||
models: {
|
||||
units: testUnits.reduce(
|
||||
(acc, unitId) => Object.assign(acc, {
|
||||
[unitId]: {
|
||||
contentType: 'other',
|
||||
title: unitId,
|
||||
},
|
||||
}),
|
||||
{},
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
const mockData = {
|
||||
unitId: '1',
|
||||
onNavigate: () => {},
|
||||
@@ -73,7 +59,7 @@ describe('Sequence Navigation Dropdown', () => {
|
||||
onNavigate={onNavigate}
|
||||
/>, { initialState });
|
||||
|
||||
screen.getAllByText(/^\d$/).forEach(element => fireEvent.click(element));
|
||||
screen.getAllByText(/^\d+$/).forEach(element => fireEvent.click(element));
|
||||
expect(onNavigate).toHaveBeenCalledTimes(testUnits.length);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import { render, screen } from '../../../../setupTest';
|
||||
import SequenceNavigationTabs from './SequenceNavigationTabs';
|
||||
import useIndexOfLastVisibleChild from '../../../../tabs/useIndexOfLastVisibleChild';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { fireEvent } from '@testing-library/dom';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import { render, screen } from '../../../../setupTest';
|
||||
import UnitButton from './UnitButton';
|
||||
|
||||
describe('Unit Button', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import { render, screen } from '../../../../setupTest';
|
||||
import UnitIcon from './UnitIcon';
|
||||
|
||||
describe('Unit Icon', () => {
|
||||
|
||||
@@ -1,48 +1,11 @@
|
||||
import React from 'react';
|
||||
import { fireEvent } from '@testing-library/dom';
|
||||
import { render, screen } from '../../../../test/test-utils';
|
||||
import {
|
||||
initialState, render, screen, testUnits,
|
||||
} from '../../../../setupTest';
|
||||
import UnitNavigation from './UnitNavigation';
|
||||
|
||||
describe('Unit Navigation', () => {
|
||||
const testUnits = [...Array(10).keys()].map(i => String(i + 1));
|
||||
const initialState = {
|
||||
courseware: {
|
||||
sequenceStatus: 'loaded',
|
||||
courseStatus: 'loaded',
|
||||
courseId: '1',
|
||||
},
|
||||
models: {
|
||||
courses: {
|
||||
1: {
|
||||
sectionIds: ['1'],
|
||||
},
|
||||
},
|
||||
sections: {
|
||||
1: {
|
||||
sequenceIds: ['1', '2'],
|
||||
},
|
||||
},
|
||||
sequences: {
|
||||
1: {
|
||||
unitIds: testUnits,
|
||||
showCompletion: true,
|
||||
},
|
||||
2: {
|
||||
unitIds: testUnits,
|
||||
showCompletion: true,
|
||||
},
|
||||
},
|
||||
units: testUnits.reduce(
|
||||
(acc, unitId) => Object.assign(acc, {
|
||||
[unitId]: {
|
||||
contentType: 'other',
|
||||
title: unitId,
|
||||
},
|
||||
}),
|
||||
{},
|
||||
),
|
||||
},
|
||||
};
|
||||
const mockData = {
|
||||
sequenceId: '1',
|
||||
unitId: '2',
|
||||
|
||||
Reference in New Issue
Block a user