Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgrady committed Aug 11, 2023
1 parent a640213 commit d118cb8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
5 changes: 0 additions & 5 deletions src/components/GoalTimeline/Redux/GoalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
incrementCurrentGoalStepAction,
loadUserEditsAction,
setCurrentGoalAction,
// setCurrentGoalIndexAction,
setCurrentGoalsStateAction,
setGoalDataAction,
updateStepFromDataAction,
Expand Down Expand Up @@ -45,10 +44,6 @@ export function setCurrentGoal(goal?: Goal): PayloadAction {
return setCurrentGoalAction({ ...goal });
}

// export function setCurrentGoalIndex(index: number): PayloadAction {
// return setCurrentGoalIndexAction(index);
// }

export function setCurrentGoalStatus(status: GoalStatus): PayloadAction {
return setCurrentGoalsStateAction(status);
}
Expand Down
8 changes: 0 additions & 8 deletions src/components/GoalTimeline/Redux/GoalReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export const goalSlice = createSlice({
? state.currentGoal.goalType
: state.previousGoalType;
},
// setCurrentGoalIndexAction: (state, action) => {
// state.currentGoal.index = action.payload;
// },
setCurrentGoalsStateAction: (state, action) => {
state.currentGoal.status = action.payload;
},
Expand All @@ -70,16 +67,11 @@ export const goalSlice = createSlice({
builder.addCase(StoreActionTypes.RESET, () => defaultState),
});

// export const actionType = (actionName: string) => {
// return `${goalSlice.name}/${actionName}Action`;
// };

export const {
addCompletedMergeToGoalAction,
incrementCurrentGoalStepAction,
loadUserEditsAction,
setCurrentGoalAction,
// setCurrentGoalIndexAction,
setCurrentGoalsStateAction,
setGoalDataAction,
updateStepFromDataAction,
Expand Down
45 changes: 29 additions & 16 deletions src/components/GoalTimeline/tests/GoalRedux.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
asyncAdvanceStep,
asyncGetUserEdits,
asyncUpdateGoal,
setCurrentGoal,
} from "components/GoalTimeline/Redux/GoalActions";
import {
CharacterChange,
Expand Down Expand Up @@ -163,20 +162,6 @@ describe("asyncGetUserEdits", () => {
});
});

describe("asyncAddCompletedMergeToGoal", () => {
it("dispatch action", async () => {
const store = setupStore();
await act(async () => {
renderWithProviders(<GoalTimeline />, { store: store });
store.dispatch(setCurrentGoal(new MergeDups()));
store.dispatch(asyncAddCompletedMergeToGoal(mockCompletedMerge));
});
const changes = store.getState().goalsState.currentGoal
.changes as MergesCompleted;
expect(changes.merges).toEqual([mockCompletedMerge]);
});
});

describe("asyncAddGoal", () => {
it("new MergeDups goal", async () => {
LocalStorage.setCurrentUser(mockUser);
Expand Down Expand Up @@ -293,7 +278,7 @@ describe("asyncUpdateGoal", () => {
await act(async () => {
renderWithProviders(<GoalTimeline />, { store: store });
});
// create mergeDups goal
// create CreateCharInv goal
const goal = new CreateCharInv();
await act(async () => {
store.dispatch(asyncAddGoal(goal));
Expand All @@ -317,4 +302,32 @@ describe("asyncUpdateGoal", () => {
// - backend is called to addGoalToUserEdit
expect(mockAddGoalToUserEdit).toBeCalled();
});
it("update MergeDups goal", async () => {
// setup the test scenario
LocalStorage.setCurrentUser(mockUser);
LocalStorage.setProjectId("123");
const store = setupStore();
await act(async () => {
renderWithProviders(<GoalTimeline />, { store: store });
});
// create MergeDups goal
const goal = new MergeDups();
await act(async () => {
store.dispatch(asyncAddGoal(goal));
});
// - dispatch asyncUpdateGoal(new goal)
await act(async () => {
await store.dispatch(asyncAddCompletedMergeToGoal(mockCompletedMerge));
await store.dispatch(
asyncUpdateGoal(store.getState().goalsState.currentGoal)
);
});
// verify:
// - current value is now new goal
const changes = store.getState().goalsState.currentGoal
.changes as MergesCompleted;
expect(changes.merges).toEqual([mockCompletedMerge]);
// - backend is called to addGoalToUserEdit
expect(mockAddGoalToUserEdit).toBeCalled();
});
});

0 comments on commit d118cb8

Please sign in to comment.