[TNL-7268] Add high priority tests

This commit is contained in:
Agrendalath
2020-06-29 03:56:42 +02:00
committed by David Joy
parent ec7f532bc9
commit 8719fad091
14 changed files with 1155 additions and 355 deletions

View File

@@ -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: () => {},

View File

@@ -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);
});
});

View File

@@ -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';

View File

@@ -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', () => {

View File

@@ -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', () => {

View File

@@ -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',