Skip to content

Commit cedbdf4

Browse files
committed
Remove component from reduxt testing
1 parent f04266c commit cedbdf4

File tree

2 files changed

+5
-63
lines changed

2 files changed

+5
-63
lines changed

src/components/Login/Captcha.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
44
import { toast } from "react-toastify";
55

66
import { verifyCaptchaToken } from "backend";
7-
import i18n from "i18n";
87
import { RuntimeConfig } from "types/runtimeConfig";
98
import theme from "types/theme";
109

@@ -17,7 +16,7 @@ export interface CaptchaProps {
1716
export default function Captcha(props: CaptchaProps): ReactElement {
1817
const setSuccess = props.setSuccess;
1918
const isRequired = useRef(RuntimeConfig.getInstance().captchaRequired());
20-
const { t } = useTranslation();
19+
const { i18n, t } = useTranslation();
2120

2221
useEffect(() => {
2322
setSuccess(!isRequired.current);

src/components/GoalTimeline/tests/GoalRedux.test.tsx renamed to src/goals/Redux/tests/GoalRedux.test.ts

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import "@testing-library/jest-dom";
22
import { act, cleanup } from "@testing-library/react";
33

4-
import { Edit, MergeUndoIds, Permission, User, UserEdit } from "api/models";
4+
import { Edit, MergeUndoIds, User, UserEdit } from "api/models";
55
import * as LocalStorage from "backend/localStorage";
6-
import GoalTimeline from "components/GoalTimeline";
76
import {
87
CharInvChanges,
98
CharInvData,
@@ -32,48 +31,31 @@ import { GoalStatus, GoalType } from "types/goals";
3231
import { Path } from "types/path";
3332
import { newUser } from "types/user";
3433
import * as goalUtilities from "utilities/goalUtilities";
35-
import { renderWithProviders } from "utilities/testingLibraryUtilities";
3634

3735
jest.mock("backend", () => ({
3836
addGoalToUserEdit: (...args: any[]) => mockAddGoalToUserEdit(...args),
39-
addStepToGoal: (...args: any[]) => mockAddStepToGoal(...args),
37+
addStepToGoal: () => jest.fn(),
4038
createUserEdit: () => mockCreateUserEdit(),
41-
findDuplicates: () => Promise.resolve(),
42-
getCurrentPermissions: () => mockGetCurrentPermissions(),
39+
findDuplicates: () => jest.fn(),
4340
getGraylistEntries: () => Promise.resolve([]),
44-
getUser: (id: string) => mockGetUser(id),
4541
getUserEditById: (...args: any[]) => mockGetUserEditById(...args),
46-
hasGraylistEntries: () => Promise.resolve(false),
42+
hasGraylistEntries: () => jest.fn(),
4743
retrieveDuplicates: () => mockRetrieveDuplicates(),
48-
updateUser: (user: User) => mockUpdateUser(user),
4944
}));
50-
jest.mock("components/Project/ProjectActions", () => ({}));
51-
jest.mock("components/Pronunciations/Recorder");
5245
jest.mock("router/browserRouter", () => ({
5346
navigate: (path: Path) => mockNavigate(path),
5447
}));
5548

5649
const mockAddGoalToUserEdit = jest.fn();
57-
const mockAddStepToGoal = jest.fn();
5850
const mockCreateUserEdit = jest.fn();
59-
const mockGetCurrentPermissions = jest.fn();
60-
const mockGetUser = jest.fn();
6151
const mockGetUserEditById = jest.fn();
6252
const mockNavigate = jest.fn();
6353
const mockRetrieveDuplicates = jest.fn();
64-
const mockUpdateUser = jest.fn();
6554
function setMockFunctions(): void {
6655
mockAddGoalToUserEdit.mockResolvedValue(0);
67-
mockAddStepToGoal.mockResolvedValue(0);
6856
mockCreateUserEdit.mockResolvedValue(mockUser());
69-
mockGetCurrentPermissions.mockResolvedValue([
70-
Permission.CharacterInventory,
71-
Permission.MergeAndReviewEntries,
72-
]);
73-
mockGetUser.mockResolvedValue(mockUser());
7457
mockGetUserEditById.mockResolvedValue(mockUserEdit(true));
7558
mockRetrieveDuplicates.mockResolvedValue(goalDataMock.plannedWords);
76-
mockUpdateUser.mockResolvedValue(mockUser());
7759
}
7860

7961
const mockProjectId = "123";
@@ -124,7 +106,6 @@ describe("setCurrentGoal", () => {
124106
it("calls setCurrentGoal() with no arguments", async () => {
125107
const store = setupStore();
126108
await act(async () => {
127-
renderWithProviders(<GoalTimeline />, { store: store });
128109
store.dispatch(setCurrentGoal());
129110
});
130111
expect(store.getState().goalsState.currentGoal.goalType).toEqual(
@@ -136,9 +117,6 @@ describe("setCurrentGoal", () => {
136117
describe("asyncGetUserEdits", () => {
137118
it("backend returns user edits", async () => {
138119
const store = setupStore();
139-
await act(async () => {
140-
renderWithProviders(<GoalTimeline />, { store: store });
141-
});
142120
const convertEditToGoalSpy = jest.spyOn(goalUtilities, "convertEditToGoal");
143121
await act(async () => {
144122
await store.dispatch(asyncGetUserEdits());
@@ -148,14 +126,9 @@ describe("asyncGetUserEdits", () => {
148126
});
149127

150128
it("backend returns no user edits", async () => {
151-
// render the GoalTimeline
152129
const store = setupStore();
153-
await act(async () => {
154-
renderWithProviders(<GoalTimeline />, { store: store });
155-
});
156130

157131
// setup mocks for testing the action/reducers
158-
jest.clearAllMocks();
159132
const convertEditToGoalSpy = jest.spyOn(goalUtilities, "convertEditToGoal");
160133
mockGetUserEditById.mockResolvedValueOnce(mockUserEdit(false));
161134

@@ -169,9 +142,6 @@ describe("asyncGetUserEdits", () => {
169142

170143
it("creates new user edits", async () => {
171144
const store = setupStore();
172-
await act(async () => {
173-
renderWithProviders(<GoalTimeline />, { store: store });
174-
});
175145
LocalStorage.setCurrentUser(newUser());
176146
await act(async () => {
177147
await store.dispatch(asyncGetUserEdits());
@@ -184,10 +154,6 @@ describe("asyncGetUserEdits", () => {
184154
describe("asyncAddGoal", () => {
185155
it("adds new MergeDups goal", async () => {
186156
const store = setupStore();
187-
await act(async () => {
188-
renderWithProviders(<GoalTimeline />, { store: store });
189-
});
190-
191157
await act(async () => {
192158
await store.dispatch(asyncAddGoal(new MergeDups()));
193159
});
@@ -201,10 +167,6 @@ describe("asyncAddGoal", () => {
201167

202168
it("adds new CreateCharInv goal", async () => {
203169
const store = setupStore();
204-
await act(async () => {
205-
renderWithProviders(<GoalTimeline />, { store: store });
206-
});
207-
208170
await act(async () => {
209171
await store.dispatch(asyncAddGoal(new CreateCharInv()));
210172
});
@@ -225,10 +187,6 @@ describe("asyncAddGoal", () => {
225187
describe("asyncLoadNewGoalData", () => {
226188
it("loads data for MergeDups goal", async () => {
227189
const store = setupStore();
228-
await act(async () => {
229-
renderWithProviders(<GoalTimeline />, { store: store });
230-
});
231-
232190
await act(async () => {
233191
await store.dispatch(asyncAddGoal(new MergeDups()));
234192
await store.dispatch(asyncLoadNewGoalData());
@@ -247,9 +205,6 @@ describe("asyncAdvanceStep", () => {
247205
it("advance MergeDups goal", async () => {
248206
// setup the test scenario
249207
const store = setupStore();
250-
await act(async () => {
251-
renderWithProviders(<GoalTimeline />, { store: store });
252-
});
253208
// create mergeDups goal
254209
await act(async () => {
255210
await store.dispatch(asyncAddGoal(new MergeDups()));
@@ -282,9 +237,6 @@ describe("asyncAdvanceStep", () => {
282237
it("advance CreateCharInv goal", async () => {
283238
// setup the test scenario
284239
const store = setupStore();
285-
await act(async () => {
286-
renderWithProviders(<GoalTimeline />, { store: store });
287-
});
288240
// create character inventory goal
289241
const goal = new CreateCharInv();
290242
await act(async () => {
@@ -304,9 +256,6 @@ describe("asyncUpdateGoal", () => {
304256
it("update CreateCharInv goal", async () => {
305257
// setup the test scenario
306258
const store = setupStore();
307-
await act(async () => {
308-
renderWithProviders(<GoalTimeline />, { store: store });
309-
});
310259
// create CreateCharInv goal
311260
const goal = new CreateCharInv();
312261
await act(async () => {
@@ -327,9 +276,6 @@ describe("asyncUpdateGoal", () => {
327276
it("update MergeDups goal", async () => {
328277
// setup the test scenario
329278
const store = setupStore();
330-
await act(async () => {
331-
renderWithProviders(<GoalTimeline />, { store: store });
332-
});
333279
// create MergeDups goal
334280
const goal = new MergeDups();
335281
await act(async () => {
@@ -352,9 +298,6 @@ describe("asyncUpdateGoal", () => {
352298
it("update ReviewDeferredDups goal", async () => {
353299
// setup the test scenario
354300
const store = setupStore();
355-
await act(async () => {
356-
renderWithProviders(<GoalTimeline />, { store: store });
357-
});
358301
// create ReviewDeferredDups goal
359302
const goal = new ReviewDeferredDups();
360303
await act(async () => {

0 commit comments

Comments
 (0)