fix: resolve tour state update error (#415)
This commit is contained in:
@@ -153,11 +153,10 @@ describe('toursReducer', () => {
|
||||
|
||||
it('handles the updateUserDiscussionsTourSuccess action', () => {
|
||||
const initialState = {
|
||||
tours: {
|
||||
tours: [{ id: 1 }, { id: 2 }],
|
||||
loading: true,
|
||||
error: null,
|
||||
},
|
||||
tours: [
|
||||
{ id: 1 },
|
||||
{ id: 2 },
|
||||
],
|
||||
};
|
||||
const updatedTour = {
|
||||
id: 2,
|
||||
@@ -165,11 +164,7 @@ describe('toursReducer', () => {
|
||||
};
|
||||
const state = toursReducer(initialState, updateUserDiscussionsTourSuccess(updatedTour));
|
||||
expect(state.tours)
|
||||
.toEqual({
|
||||
tours: [{ id: 1 }, updatedTour],
|
||||
loading: RequestStatus.SUCCESSFUL,
|
||||
error: null,
|
||||
});
|
||||
.toEqual([{ id: 1 }, updatedTour]);
|
||||
});
|
||||
|
||||
it('handles the discussionsToursRequestError action', () => {
|
||||
|
||||
@@ -26,10 +26,10 @@ const userDiscussionsToursSlice = createSlice({
|
||||
state.error = action.payload;
|
||||
},
|
||||
updateUserDiscussionsTourSuccess: (state, action) => {
|
||||
const tourIndex = state.tours.tours.findIndex(tour => tour.id === action.payload.id);
|
||||
state.tours.tours[tourIndex] = action.payload;
|
||||
state.tours.loading = RequestStatus.SUCCESSFUL;
|
||||
state.tours.error = null;
|
||||
const tourIndex = state.tours.findIndex(tour => tour.id === action.payload.id);
|
||||
state.tours[tourIndex] = action.payload;
|
||||
state.loading = RequestStatus.SUCCESSFUL;
|
||||
state.error = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user