|
1 |
| -import { screen, waitFor } from '@testing-library/react'; |
| 1 | +import { act, screen, waitFor } from '@testing-library/react'; |
2 | 2 | import type { RenderOptions } from '@testing-library/react';
|
3 | 3 | import { Provider } from 'react-redux';
|
4 | 4 | import axios, { AxiosHeaders, AxiosResponse } from 'axios';
|
@@ -189,16 +189,19 @@ describe(TimetableContainerComponent, () => {
|
189 | 189 | test('should display saved timetable when there is no imported timetable', async () => {
|
190 | 190 | const semester = 1;
|
191 | 191 | const location = timetablePage(semester);
|
192 |
| - // TODO: Get this test to work with the new createRoot API, i.e. legacyRoot = false. |
193 |
| - const { store } = make(location, { renderOptions: { legacyRoot: true } }); |
| 192 | + const { store } = make(location); |
194 | 193 |
|
195 | 194 | // Populate moduleBank using "succeeded" requests-middleware requests
|
196 |
| - store.dispatch({ type: SUCCESS_KEY(FETCH_MODULE), payload: CS1010S }); |
197 |
| - store.dispatch({ type: SUCCESS_KEY(FETCH_MODULE), payload: CS3216 }); |
| 195 | + await act(async () => { |
| 196 | + store.dispatch({ type: SUCCESS_KEY(FETCH_MODULE), payload: CS1010S }); |
| 197 | + store.dispatch({ type: SUCCESS_KEY(FETCH_MODULE), payload: CS3216 }); |
| 198 | + }); |
198 | 199 |
|
199 | 200 | // Populate mock timetable
|
200 |
| - const timetable = { CS1010S: { Lecture: '1' }, CS3216: { Lecture: '1' } }; |
201 |
| - (store.dispatch as Dispatch)(setTimetable(semester, timetable)); |
| 201 | + await act(async () => { |
| 202 | + const timetable = { CS1010S: { Lecture: '1' }, CS3216: { Lecture: '1' } }; |
| 203 | + (store.dispatch as Dispatch)(setTimetable(semester, timetable)); |
| 204 | + }); |
202 | 205 |
|
203 | 206 | // Expect nothing to be fetched as timetable exists in `moduleBank`.
|
204 | 207 | expect(screen.queryByText(/Loading/)).not.toBeInTheDocument();
|
|
0 commit comments