diff --git a/src/app/modules/customer-management/store/customer-management.effects.spec.ts b/src/app/modules/customer-management/store/customer-management.effects.spec.ts index 01371017..86ff45c4 100644 --- a/src/app/modules/customer-management/store/customer-management.effects.spec.ts +++ b/src/app/modules/customer-management/store/customer-management.effects.spec.ts @@ -88,11 +88,12 @@ describe('CustomerEffects', () => { it('action type is CREATE_CUSTOMER_FAIL when service fail in execution', async () => { actions$ = of({ type: CustomerManagementActionTypes.CREATE_CUSTOMER, payload: customer }); + spyOn(toastrService, 'error'); - spyOn(service, 'createCustomer').and.returnValue(throwError({ error: { message: 'fail!' } })); + spyOn(service, 'createCustomer').and.returnValue(throwError({ error: 'Duplicated' })); effects.createCustomer$.subscribe((action) => { - expect(toastrService.error).toHaveBeenCalled(); + expect(toastrService.error).toHaveBeenCalledWith('Duplicated'); expect(action.type).toEqual(CustomerManagementActionTypes.CREATE_CUSTOMER_FAIL); }); }); diff --git a/src/app/modules/customer-management/store/customer-management.effects.ts b/src/app/modules/customer-management/store/customer-management.effects.ts index 7485396b..4a4b6f4d 100644 --- a/src/app/modules/customer-management/store/customer-management.effects.ts +++ b/src/app/modules/customer-management/store/customer-management.effects.ts @@ -46,7 +46,7 @@ export class CustomerEffects { return new actions.CreateCustomerSuccess(customerData); }), catchError((error) => { - this.toastrService.error(error.error.message); + this.toastrService.error(error.error); return of(new actions.CreateCustomerFail(error)); }) )