Skip to content

Commit d564d18

Browse files
committed
CS + cleanup
1 parent 95972fb commit d564d18

File tree

3 files changed

+23
-54
lines changed

3 files changed

+23
-54
lines changed

src/test/components/ng-http-loader.component.spec.ts

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,8 @@ describe('NgHttpLoaderComponent', () => {
129129
});
130130

131131
it('should show and hide the spinner according to the pending HTTP requests', fakeAsync(() => {
132-
function runQuery$(url: string): Observable<any> {
133-
return http.get(url);
134-
}
135-
132+
const runQuery$ = (url: string): Observable<any> => http.get(url);
136133
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
137-
138134
const firstRequest = httpMock.expectOne('/fake');
139135
const secondRequest = httpMock.expectOne('/fake2');
140136

@@ -397,13 +393,8 @@ describe('NgHttpLoaderComponent', () => {
397393

398394
it('should correctly handle the debounce delay for multiple HTTP requests', fakeAsync(() => {
399395
component.debounceDelay = 2000;
400-
401-
function runQuery$(url: string): Observable<any> {
402-
return http.get(url);
403-
}
404-
396+
const runQuery$ = (url: string): Observable<any> => http.get(url);
405397
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
406-
407398
const firstRequest = httpMock.expectOne('/fake');
408399
const secondRequest = httpMock.expectOne('/fake2');
409400

@@ -544,13 +535,8 @@ describe('NgHttpLoaderComponent', () => {
544535

545536
it('should correctly handle the minimum spinner duration for multiple HTTP requests', fakeAsync(() => {
546537
component.minDuration = 5000;
547-
548-
function runQuery$(url: string): Observable<any> {
549-
return http.get(url);
550-
}
551-
538+
const runQuery$ = (url: string): Observable<any> => http.get(url);
552539
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
553-
554540
const firstRequest = httpMock.expectOne('/fake');
555541
const secondRequest = httpMock.expectOne('/fake2');
556542

@@ -587,13 +573,8 @@ describe('NgHttpLoaderComponent', () => {
587573

588574
it('should correctly handle the extra spinner duration for multiple HTTP requests', fakeAsync(() => {
589575
component.extraDuration = 5000;
590-
591-
function runQuery$(url: string): Observable<any> {
592-
return http.get(url);
593-
}
594-
576+
const runQuery$ = (url: string): Observable<any> => http.get(url);
595577
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
596-
597578
const firstRequest = httpMock.expectOne('/fake');
598579
const secondRequest = httpMock.expectOne('/fake2');
599580

@@ -634,7 +615,6 @@ describe('NgHttpLoaderComponent', () => {
634615

635616
it('should correctly handle the minimum spinner duration for multiple HTTP requests ran one after the others', fakeAsync(() => {
636617
component.minDuration = 2000;
637-
638618
http.get('/fake').subscribe();
639619
const firstRequest = httpMock.expectOne('/fake');
640620

@@ -667,11 +647,7 @@ describe('NgHttpLoaderComponent', () => {
667647

668648
it('should handle the extra spinner duration for multiple HTTP requests ran one after the others', fakeAsync(() => {
669649
component.extraDuration = 10;
670-
671-
function runQuery$(url: string): Observable<any> {
672-
return http.get(url);
673-
}
674-
650+
const runQuery$ = (url: string): Observable<any> => http.get(url);
675651
runQuery$('/fake').subscribe();
676652
const firstRequest = httpMock.expectOne('/fake');
677653

src/test/services/pending-requests-interceptor.service.spec.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ describe('PendingRequestsInterceptor', () => {
3737
});
3838

3939
it('should be aware of the pending HTTP requests', () => {
40-
function runQuery$(url: string): Observable<any> {
41-
return http.get(url);
42-
}
40+
const runQuery$ = (url: string): Observable<any> => http.get(url);
4341

4442
forkJoin([runQuery$('/fake'), runQuery$('/fake2')]).subscribe();
4543

@@ -58,37 +56,34 @@ describe('PendingRequestsInterceptor', () => {
5856
});
5957

6058
it('should correctly notify the pendingRequestsStatus observable', async(() => {
61-
const pendingRequestsStatus$ = pendingRequestsInterceptor.pendingRequestsStatus$;
62-
63-
pendingRequestsStatus$
59+
pendingRequestsInterceptor
60+
.pendingRequestsStatus$
6461
.subscribe(
6562
(next: boolean) => expect(next).toBeTruthy(),
66-
(error: HttpErrorResponse) => expect(1).toBe(2)
63+
() => expect(1).toBe(2)
6764
);
6865

6966
http.get('/fake').subscribe();
7067
httpMock.expectOne('/fake');
7168
}));
7269

7370
it('should correctly notify the pendingRequestsStatus observable, even if subscribed after', async(() => {
74-
const pendingRequestsStatus$ = pendingRequestsInterceptor.pendingRequestsStatus$;
75-
76-
7771
http.get('/fake').subscribe();
7872
httpMock.expectOne('/fake');
7973

80-
pendingRequestsStatus$
74+
pendingRequestsInterceptor
75+
.pendingRequestsStatus$
8176
.subscribe(
8277
(next: boolean) => expect(next).toBeTruthy(),
83-
(error: HttpErrorResponse) => expect(1).toBe(2)
78+
() => expect(1).toBe(2)
8479
);
8580
}));
8681

8782
it('should fail correctly', () => {
8883
const statusText = 'NOT FOUND';
8984

9085
http.get('/fake').subscribe(
91-
(next: boolean) => expect(true).toBe(false),
86+
() => expect(true).toBe(false),
9287
(error: HttpErrorResponse) => expect(error.statusText).toBe(statusText)
9388
);
9489

src/test/services/spinner-visibility.service.spec.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,19 @@ describe('SpinnerVisibilityService', () => {
2828

2929
it('should pipe \'true\' when calling show()', () => {
3030
spinnerVisibilityService.show();
31-
spinnerVisibilityService.visibility$.subscribe(result => {
32-
expect(result).toBeTruthy();
33-
},
34-
error => {
35-
expect(true).toBeFalsy();
36-
});
31+
spinnerVisibilityService.visibility$
32+
.subscribe(
33+
result => expect(result).toBeTruthy(),
34+
() => expect(true).toBeFalsy()
35+
);
3736
});
3837

3938
it('should pipe \'false\' when calling hide()', () => {
4039
spinnerVisibilityService.hide();
41-
spinnerVisibilityService.visibility$.subscribe(result => {
42-
expect(result).toBeFalsy();
43-
},
44-
error => {
45-
expect(true).toBeFalsy();
46-
});
40+
spinnerVisibilityService.visibility$
41+
.subscribe(
42+
result => expect(result).toBeFalsy(),
43+
() => expect(true).toBeFalsy()
44+
);
4745
});
4846
});

0 commit comments

Comments
 (0)