From 6ec0660c19ea62e482aba558aa72c8cc35364f33 Mon Sep 17 00:00:00 2001 From: mmaquina Date: Mon, 24 Jul 2023 17:28:40 -0300 Subject: [PATCH 1/2] fix: TTL-836 customer duplicated error message --- .../store/customer-management.effects.spec.ts | 7 ++++--- .../store/customer-management.effects.ts | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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 013710175..709de03d6 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 @@ -10,7 +10,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ToastrModule, ToastrService } from 'ngx-toastr'; import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../shared/messages'; -describe('CustomerEffects', () => { +fdescribe('CustomerEffects', () => { let actions$: Observable; let effects: CustomerEffects; let service: CustomerService; @@ -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 7485396b7..e57d00127 100644 --- a/src/app/modules/customer-management/store/customer-management.effects.ts +++ b/src/app/modules/customer-management/store/customer-management.effects.ts @@ -1,4 +1,4 @@ -import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../shared/messages'; +import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY, DUPLICATED_ERROR } from '../../shared/messages'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Action } from '@ngrx/store'; @@ -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)); }) ) From 0097adf94a0c0a6aeba82a1a699e88d39bb5ab5d Mon Sep 17 00:00:00 2001 From: mmaquina Date: Mon, 24 Jul 2023 17:35:00 -0300 Subject: [PATCH 2/2] fix: TTL-836 fdescribe -> describe --- .../store/customer-management.effects.spec.ts | 2 +- .../customer-management/store/customer-management.effects.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 709de03d6..86ff45c46 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 @@ -10,7 +10,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ToastrModule, ToastrService } from 'ngx-toastr'; import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../shared/messages'; -fdescribe('CustomerEffects', () => { +describe('CustomerEffects', () => { let actions$: Observable; let effects: CustomerEffects; let service: CustomerService; 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 e57d00127..4a4b6f4d7 100644 --- a/src/app/modules/customer-management/store/customer-management.effects.ts +++ b/src/app/modules/customer-management/store/customer-management.effects.ts @@ -1,4 +1,4 @@ -import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY, DUPLICATED_ERROR } from '../../shared/messages'; +import { INFO_SAVED_SUCCESSFULLY, INFO_DELETE_SUCCESSFULLY } from '../../shared/messages'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Action } from '@ngrx/store';