Skip to content

Commit fe5b055

Browse files
author
Abigail Cabascango
committed
refactor: TTA-115 unit test for function checkTypeError in status network service
1 parent 07809f5 commit fe5b055

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/app/modules/shared/services/status-network.service.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ describe('StatusNetworkService', () => {
2525
service = TestBed.inject(StatusNetworkService);
2626
});
2727

28-
fit('checkTypeError is error', () => {
28+
it('checkTypeError is error', () => {
2929
const errorType: ErrorType = {error: catchError, message: 'javascript', isError: true};
3030
spyOn(toastrServiceStub, 'error');
31-
service.checkTypeError(errorType)
31+
service.checkTypeError(errorType);
3232
expect(toastrServiceStub.error).toHaveBeenCalled();
3333
});
3434

35-
fit('checkTypeError is warning', () => {
35+
it('checkTypeError is warning', () => {
3636
const errorType: ErrorType = {error: catchError, message: 'javascript', isError: false};
3737
spyOn(toastrServiceStub, 'warning');
38-
service.checkTypeError(errorType)
38+
service.checkTypeError(errorType);
3939
expect(toastrServiceStub.warning).toHaveBeenCalled();
4040
});
4141
});

src/app/modules/shared/services/status-network.service.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export class StatusNetworkService {
1717
) { }
1818

1919
checkTypeError(dataError: ErrorType){
20-
const { isError = false, message = 'The server is disconnected', error} = dataError;
21-
const effectiveTypenetwork = navigator.connection;
22-
if ((effectiveTypenetwork.effectiveType != '2g')){
23-
if(!isError){
24-
this.toastrService.warning(message);
25-
}
26-
if(isError){
27-
const errorMessa = error.error && error.error.message? error.error.message: 'There is an error with the server, your request have not be completed';
28-
this.toastrService.error(errorMessa);
29-
}
20+
const { isError = false, message = 'The server is disconnected', error} = dataError;
21+
const effectiveTypenetwork = navigator.connection;
22+
if ((effectiveTypenetwork.effectiveType !== '2g')){
23+
if (!isError){
24+
this.toastrService.warning(message);
3025
}
31-
this.toastrService.warning('Your request was not completed, your connection is slow');
26+
if (isError){
27+
const errorMessa = error.error && error.error.message ? error.error.message : 'There is an error with the server, your request have not be completed';
28+
this.toastrService.error(errorMessa);
29+
}
30+
}
31+
this.toastrService.warning('Your request was not completed, your connection is slow');
3232
}
3333
}

0 commit comments

Comments
 (0)