Skip to content

Commit afc4672

Browse files
committed
fix: #170 avoid clearing lists on errors
1 parent 0463a02 commit afc4672

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

src/app/modules/activities-management/store/activity-management.reducers.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ describe('activityManagementReducer', () => {
2323
expect(state.data).toEqual(activitiesFound);
2424
});
2525

26-
it('on LoadActivitiesFail, message equal to Something went wrong fetching activities!', () => {
26+
it('loading is false on LoadActivitiesFail', () => {
2727
const action = new actions.LoadActivitiesFail('error');
2828

2929
const state = activityManagementReducer(initialState, action);
3030

31-
expect(state.message).toEqual('Something went wrong fetching activities!');
31+
expect(state.isLoading).toBeFalsy();
3232
});
3333

3434
it('on CreateActivity, isLoading is true', () => {
@@ -48,12 +48,11 @@ describe('activityManagementReducer', () => {
4848
expect(state.isLoading).toEqual(false);
4949
});
5050

51-
it('on CreateActivityFail, message equal to Something went wrong creating activities!', () => {
51+
it('is Loading false on CreateActivityFail', () => {
5252
const action = new actions.CreateActivityFail('error');
5353

5454
const state = activityManagementReducer(initialState, action);
5555

56-
expect(state.message).toEqual('Something went wrong creating activities!');
5756
expect(state.isLoading).toEqual(false);
5857
});
5958

src/app/modules/activities-management/store/activity-management.reducers.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export function activityManagementReducer(state: ActivityState = initialState, a
3434
};
3535
}
3636
case ActivityManagementActionTypes.LOAD_ACTIVITIES_FAIL: {
37-
return { data: [], isLoading: false, message: 'Something went wrong fetching activities!', activityIdToEdit: '' };
37+
return {
38+
...state,
39+
isLoading: false,
40+
};
3841
}
3942

4043
case ActivityManagementActionTypes.CREATE_ACTIVITY: {
@@ -55,10 +58,8 @@ export function activityManagementReducer(state: ActivityState = initialState, a
5558

5659
case ActivityManagementActionTypes.CREATE_ACTIVITY_FAIL: {
5760
return {
58-
data: [],
61+
...state,
5962
isLoading: false,
60-
message: 'Something went wrong creating activities!',
61-
activityIdToEdit: '',
6263
};
6364
}
6465

@@ -133,7 +134,7 @@ export function activityManagementReducer(state: ActivityState = initialState, a
133134
};
134135
}
135136

136-
default : {
137+
default: {
137138
return state;
138139
}
139140

src/app/modules/customer-management/components/projects-type/store/project-type.reducers.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ describe('projectTypeReducer', () => {
5454
expect(state.isLoading).toEqual(false);
5555
});
5656

57-
it('on CreateProjectTypeFail, message equal to Something went wrong creating projectType!', () => {
57+
it('isLoading false on CreateProjectTypeFail', () => {
5858
const action = new actions.CreateProjectTypeFail('error');
5959

6060
const state = projectTypeReducer(initialState, action);
6161

62-
expect(state.message).toEqual('Something went wrong creating projectType!');
6362
expect(state.isLoading).toEqual(false);
6463
});
6564

src/app/modules/customer-management/components/projects-type/store/project-type.reducers.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ export const projectTypeReducer = (state: ProjectTypeState = initialState, actio
6060

6161
case ProjectTypeActionTypes.CREATE_PROJECT_TYPE_FAIL: {
6262
return {
63-
data: [],
63+
...state,
6464
isLoading: false,
65-
message: 'Something went wrong creating projectType!',
66-
projectTypeIdToEdit: '',
6765
};
6866
}
6967

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TechnologiesComponent } from './../technologies/technologies.component';
12
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
23
import { provideMockStore, MockStore } from '@ngrx/store/testing';
34
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -6,7 +7,6 @@ import { formatDate } from '@angular/common';
67
import { TechnologyState } from '../../store/technology.reducers';
78
import { allTechnologies } from '../../store/technology.selectors';
89
import { DetailsFieldsComponent } from './details-fields.component';
9-
import * as actions from '../../store/technology.actions';
1010
import { ProjectState } from '../../../customer-management/components/projects/components/store/project.reducer';
1111
import { getCustomerProjects } from '../../../customer-management/components/projects/components/store/project.selectors';
1212
import { EntryState } from '../../../time-clock/store/entry.reducer';
@@ -61,7 +61,7 @@ describe('DetailsFieldsComponent', () => {
6161

6262
beforeEach(async(() => {
6363
TestBed.configureTestingModule({
64-
declarations: [DetailsFieldsComponent],
64+
declarations: [DetailsFieldsComponent, TechnologiesComponent],
6565
providers: [provideMockStore({ initialState: state })],
6666
imports: [FormsModule, ReactiveFormsModule],
6767
}).compileComponents();

0 commit comments

Comments
 (0)