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
refactor: TTA-115 changed test descriptions - lint
  • Loading branch information
mmaquina committed Oct 11, 2022
commit aabefafc463aadb9aec242494cefbb1c32e1cc08
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ export class ConnectionDirective implements OnInit {

ngOnInit() {
const { effectiveType } = navigator.connection;
let networkSatus;
let networkStatus;
if (/\fast-5g|3g|4g/.test(effectiveType)) {
networkSatus = this.fastSrc;
return;
networkStatus = this.fastSrc;
} else if (/\slow-2g|2g/.test(effectiveType)) {
networkStatus = this.slowSrc;
} else {
networkStatus = this.offlineSrc;
}
if (/\slow-2g|2g/.test(effectiveType)) {
networkSatus = this.slowSrc;
return;
}
networkSatus = this.offlineSrc;

this.host.nativeElement.setAttribute('src', networkSatus);
this.host.nativeElement.setAttribute('src', networkStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ describe('InternetConnectionStatusComponent', () => {
fixture.detectChanges();
});

it('should show a stable connection warning', () => {
it('component.isFast should be true when the connection is 4g', () => {
component.connection$ = of('4g');
fixture.detectChanges();
component.ngOnInit();
expect(component.isFast).toBe(true);
});

it('should show a slow connection warning', () => {
it('component.isFast should be false when the connection is 2g', () => {
component.connection$ = of('2g');
fixture.detectChanges();
component.ngOnInit();
expect(component.isFast).toBe(false);
});

it('should show offline warning', () => {
it('component.isFast should be false when the connection is Offline', () => {
component.connection$ = of('Offline');
fixture.detectChanges();
component.ngOnInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ export class InternetConnectionStatusComponent implements OnInit {
this.connectionType = effectiveType;

if (/\fast-5g|3g|4g/.test(effectiveType)) {
this.toastrService.error('Your request was not completed, you are offline');
this.isFast = true;
return;
}
if (/\slow-2g|2g/.test(effectiveType)) {
this.toastrService.warning('Caution your connection is slow');
this.isFast = false;
return;
this.toastrService.warning('Caution your connection is slow');
this.isFast = false;
return;
}
this.toastrService.warning('Caution your connection is slow');
this.isFast = false;
});
}
Expand Down
9 changes: 6 additions & 3 deletions src/app/modules/time-clock/store/entry.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class EntryEffects {
return new actions.ClockIn(entry);
}),
catchError((error) => {
this.statusNetworkService.showTypeToastrServiceAlert({error, message: 'We could not perform this operation, try again later', isError: false});
this.statusNetworkService.showTypeToastrServiceAlert(
{error, message: 'We could not perform this operation, try again later', isError: false});
return of(new actions.StopTimeEntryRunningFail(error));
})
)
Expand All @@ -56,7 +57,8 @@ export class EntryEffects {
return new actions.LoadEntriesSummarySuccess(response);
}),
catchError((error) => {
this.statusNetworkService.showTypeToastrServiceAlert({error, message: 'Your summary information could not be loaded', isError: false});
this.statusNetworkService.showTypeToastrServiceAlert(
{error, message: 'Your summary information could not be loaded', isError: false});
return of(new actions.LoadEntriesSummaryFail());
})
)
Expand Down Expand Up @@ -151,7 +153,8 @@ export class EntryEffects {
if (error.status === 404) {
return of(new actions.CreateEntry(entry));
} else {
this.statusNetworkService.showTypeToastrServiceAlert({error, message: 'We could not clock you in, try again later.', isError: true});
this.statusNetworkService.showTypeToastrServiceAlert(
{error, message: 'We could not clock you in, try again later.', isError: true});
return of(new actions.CreateEntryFail('Error'));
}
})
Expand Down