Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: TTA-115 unit test for function checkTypeError in status net…
…work service
  • Loading branch information
Abigail Cabascango committed Oct 6, 2022
commit fe5b0551edf7025403d7f39170f18d4e1ea3d4a5
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ describe('StatusNetworkService', () => {
service = TestBed.inject(StatusNetworkService);
});

fit('checkTypeError is error', () => {
it('checkTypeError is error', () => {
const errorType: ErrorType = {error: catchError, message: 'javascript', isError: true};
spyOn(toastrServiceStub, 'error');
service.checkTypeError(errorType)
service.checkTypeError(errorType);
expect(toastrServiceStub.error).toHaveBeenCalled();
});

fit('checkTypeError is warning', () => {
it('checkTypeError is warning', () => {
const errorType: ErrorType = {error: catchError, message: 'javascript', isError: false};
spyOn(toastrServiceStub, 'warning');
service.checkTypeError(errorType)
service.checkTypeError(errorType);
expect(toastrServiceStub.warning).toHaveBeenCalled();
});
});
22 changes: 11 additions & 11 deletions src/app/modules/shared/services/status-network.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export class StatusNetworkService {
) { }

checkTypeError(dataError: ErrorType){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le ponemos de nombre swhowMessage?

const { isError = false, message = 'The server is disconnected', error} = dataError;
const effectiveTypenetwork = navigator.connection;
if ((effectiveTypenetwork.effectiveType != '2g')){
if(!isError){
this.toastrService.warning(message);
}
if(isError){
const errorMessa = error.error && error.error.message? error.error.message: 'There is an error with the server, your request have not be completed';
this.toastrService.error(errorMessa);
}
const { isError = false, message = 'The server is disconnected', error} = dataError;
const effectiveTypenetwork = navigator.connection;
if ((effectiveTypenetwork.effectiveType !== '2g')){
if (!isError){
this.toastrService.warning(message);
}
this.toastrService.warning('Your request was not completed, your connection is slow');
if (isError){
const errorMessa = error.error && error.error.message ? error.error.message : 'There is an error with the server, your request have not be completed';
this.toastrService.error(errorMessa);
}
}
this.toastrService.warning('Your request was not completed, your connection is slow');
}
}