Skip to content

Commit d038c10

Browse files
committed
fix: #87 c2-save-customers-tests
1 parent 016d0c6 commit d038c10

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { CreateCustomerComponent } from './create-customer';
44
import { MockStore, provideMockStore } from '@ngrx/store/testing';
5-
import { CustomerState, CreateCustomer, CreateCustomerSuccess } from 'src/app/modules/customer-management/store';
5+
import { CustomerState, CreateCustomer } from 'src/app/modules/customer-management/store';
66
import { FormBuilder, FormGroup } from '@angular/forms';
7-
import { By } from '@angular/platform-browser';
87
import { Customer } from 'src/app/modules/shared/models/customer.model';
9-
import { of } from 'rxjs';
108

119
describe('CreateCustomerComponent', () => {
1210
let component: CreateCustomerComponent;
@@ -19,13 +17,6 @@ describe('CreateCustomerComponent', () => {
1917
message: '',
2018
};
2119

22-
const message = {
23-
message() {
24-
const messageValue = 'Sucess';
25-
return messageValue;
26-
},
27-
};
28-
2920
beforeEach(async(() => {
3021
TestBed.configureTestingModule({
3122
declarations: [CreateCustomerComponent],

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,16 @@ export class CreateCustomerComponent {
2525

2626
onSubmit(customerData) {
2727
this.store.dispatch(new CreateCustomer(customerData));
28-
this.store
29-
.select((state) => state)
30-
.subscribe((state) => {
31-
this.response = Object.values(state)[2].message;
32-
if (this.response === 'Data create successfully!') {
33-
this.isActiveItemTabs = true;
34-
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
35-
this.messageToShow = this.response;
36-
} else {
37-
this.messageToShow = this.response;
38-
}
39-
});
28+
this.store.subscribe((state) => {
29+
this.response = Object.values(state)[2].message;
30+
if (this.response === 'Data create successfully!' || undefined) {
31+
this.isActiveItemTabs = true;
32+
this.changeValueIsActiveItemTabs.emit(this.isActiveItemTabs);
33+
this.messageToShow = this.response;
34+
} else {
35+
this.messageToShow = this.response;
36+
}
37+
});
4038
this.messageToShow = '';
4139
}
4240

0 commit comments

Comments
 (0)