test: refactor many test suites to use testUtils/initializeMocks (#2067)

Simplifies a bunch of test code by converting it to use our handy testUtils module.

None of the app code is change, just test code. And none of the test cases are modified in any meaningful way - this just simplifies the setup/cleanup significantly.
This commit is contained in:
Braden MacDonald
2025-06-03 13:52:56 -07:00
committed by GitHub
parent d806b6150d
commit 1dee2bba58
33 changed files with 279 additions and 892 deletions

View File

@@ -4,9 +4,7 @@ import {
initializeMocks, render, screen, within,
} from '../../testUtils';
import { getApiWaffleFlagsUrl } from '../../data/api';
import { fetchWaffleFlags } from '../../data/thunks';
import { generateCourseLaunchData } from '../factories/mockApiResponses';
import { executeThunk } from '../../utils';
import { checklistItems } from './utils/courseChecklistData';
import messages from './messages';
@@ -34,7 +32,7 @@ const renderComponent = (props) => {
describe('ChecklistSection', () => {
beforeEach(async () => {
const { axiosMock, reduxStore } = initializeMocks();
const { axiosMock } = initializeMocks();
axiosMock
.onGet(getApiWaffleFlagsUrl(courseId))
.reply(200, {
@@ -43,7 +41,6 @@ describe('ChecklistSection', () => {
useNewScheduleDetailsPage: true,
useNewCourseOutlinePage: true,
});
await executeThunk(fetchWaffleFlags(courseId), reduxStore.dispatch);
});
it('a heading using the dataHeading prop', () => {