@@ -13,9 +13,9 @@ import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angul
13
13
import { By } from '@angular/platform-browser' ;
14
14
import { forkJoin , Observable , of , Subscription } from 'rxjs' ;
15
15
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component' ;
16
+ import { pendingRequestsInterceptor$ } from '../../lib/services/pending-requests-interceptor' ;
16
17
import { SpinnerVisibilityService } from '../../lib/services/spinner-visibility.service' ;
17
18
import { Spinkit } from '../../lib/spinkits' ;
18
- import { pendingRequestsInterceptor$ } from "../../lib/services/pending-requests-interceptor" ;
19
19
20
20
describe ( 'NgHttpLoaderComponent' , ( ) => {
21
21
let component : NgHttpLoaderComponent ;
@@ -67,7 +67,7 @@ describe('NgHttpLoaderComponent', () => {
67
67
68
68
it ( 'should not set the colored class if background-color is defined' , ( ) => {
69
69
component . isVisible$ = of ( true ) ;
70
- component . backgroundColor . set ( '#ff0000' ) ;
70
+ fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
71
71
fixture . detectChanges ( ) ;
72
72
73
73
const element = fixture
@@ -101,7 +101,7 @@ describe('NgHttpLoaderComponent', () => {
101
101
102
102
it ( 'should allow us to specify a custom background-color' , ( ) => {
103
103
component . isVisible$ = of ( true ) ;
104
- component . backgroundColor . set ( '#ff0000' ) ;
104
+ fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
105
105
fixture . detectChanges ( ) ;
106
106
107
107
const element = fixture
@@ -271,7 +271,7 @@ describe('NgHttpLoaderComponent', () => {
271
271
} ) ) ;
272
272
273
273
it ( 'should correctly handle the debounce delay for a single HTTP request' , fakeAsync ( ( ) => {
274
- component . debounceDelay . set ( 2000 ) ;
274
+ fixture . componentRef . setInput ( 'debounceDelay' , 2000 ) ;
275
275
http . get ( '/fake' ) . subscribe ( ) ;
276
276
277
277
// the HTTP request is pending for 1 second now
@@ -297,7 +297,7 @@ describe('NgHttpLoaderComponent', () => {
297
297
} ) ) ;
298
298
299
299
it ( 'should correctly handle the debounce delay for HTTP request finished before spinner should be shown' , fakeAsync ( ( ) => {
300
- component . debounceDelay . set ( 2000 ) ;
300
+ fixture . componentRef . setInput ( 'debounceDelay' , 2000 ) ;
301
301
http . get ( '/fake' ) . subscribe ( ) ;
302
302
303
303
// the HTTP request is pending for 1 second now
@@ -311,7 +311,7 @@ describe('NgHttpLoaderComponent', () => {
311
311
} ) ) ;
312
312
313
313
it ( 'should correctly handle the debounce delay for HTTP sequential requests finished before spinner should be shown' , fakeAsync ( ( ) => {
314
- component . debounceDelay . set ( 5000 ) ;
314
+ fixture . componentRef . setInput ( 'debounceDelay' , 5000 ) ;
315
315
http . get ( '/fake' ) . subscribe ( ) ;
316
316
317
317
// the first HTTP request is pending for 1 second now
@@ -339,7 +339,7 @@ describe('NgHttpLoaderComponent', () => {
339
339
} ) ) ;
340
340
341
341
it ( 'should correctly handle the debounce delay for HTTP parallel requests finished before spinner should be shown' , fakeAsync ( ( ) => {
342
- component . debounceDelay . set ( 5000 ) ;
342
+ fixture . componentRef . setInput ( 'debounceDelay' , 5000 ) ;
343
343
http . get ( '/fake' ) . subscribe ( ) ;
344
344
http . get ( '/fake2' ) . subscribe ( ) ;
345
345
@@ -365,7 +365,7 @@ describe('NgHttpLoaderComponent', () => {
365
365
} ) ) ;
366
366
367
367
it ( 'should correctly handle the debounce delay for multiple HTTP requests' , fakeAsync ( ( ) => {
368
- component . debounceDelay . set ( 2000 ) ;
368
+ fixture . componentRef . setInput ( 'debounceDelay' , 2000 ) ;
369
369
const runQuery$ = ( url : string ) : Observable < unknown > => http . get ( url ) ;
370
370
forkJoin ( [ runQuery$ ( '/fake' ) , runQuery$ ( '/fake2' ) ] ) . subscribe ( ) ;
371
371
const firstRequest = httpMock . expectOne ( '/fake' ) ;
@@ -448,7 +448,7 @@ describe('NgHttpLoaderComponent', () => {
448
448
} ) ) ;
449
449
450
450
it ( 'should correctly handle the minimum spinner duration for a single HTTP request' , fakeAsync ( ( ) => {
451
- component . minDuration . set ( 5000 ) ;
451
+ fixture . componentRef . setInput ( 'minDuration' , 5000 ) ;
452
452
http . get ( '/fake' ) . subscribe ( ) ;
453
453
454
454
// the HTTP request is pending for 1 second now
@@ -482,7 +482,7 @@ describe('NgHttpLoaderComponent', () => {
482
482
} ) ) ;
483
483
484
484
it ( 'should correctly handle the extra spinner duration for a single HTTP request' , fakeAsync ( ( ) => {
485
- component . extraDuration . set ( 5000 ) ;
485
+ fixture . componentRef . setInput ( 'extraDuration' , 5000 ) ;
486
486
http . get ( '/fake' ) . subscribe ( ) ;
487
487
488
488
// the HTTP request is pending for 1 second now
@@ -508,7 +508,7 @@ describe('NgHttpLoaderComponent', () => {
508
508
} ) ) ;
509
509
510
510
it ( 'should correctly handle the minimum spinner duration for multiple HTTP requests' , fakeAsync ( ( ) => {
511
- component . minDuration . set ( 5000 ) ;
511
+ fixture . componentRef . setInput ( 'minDuration' , 5000 ) ;
512
512
const runQuery$ = ( url : string ) : Observable < unknown > => http . get ( url ) ;
513
513
forkJoin ( [ runQuery$ ( '/fake' ) , runQuery$ ( '/fake2' ) ] ) . subscribe ( ) ;
514
514
const firstRequest = httpMock . expectOne ( '/fake' ) ;
@@ -546,7 +546,7 @@ describe('NgHttpLoaderComponent', () => {
546
546
} ) ) ;
547
547
548
548
it ( 'should correctly handle the extra spinner duration for multiple HTTP requests' , fakeAsync ( ( ) => {
549
- component . extraDuration . set ( 5000 ) ;
549
+ fixture . componentRef . setInput ( 'extraDuration' , 5000 ) ;
550
550
const runQuery$ = ( url : string ) : Observable < unknown > => http . get ( url ) ;
551
551
forkJoin ( [ runQuery$ ( '/fake' ) , runQuery$ ( '/fake2' ) ] ) . subscribe ( ) ;
552
552
const firstRequest = httpMock . expectOne ( '/fake' ) ;
@@ -588,7 +588,7 @@ describe('NgHttpLoaderComponent', () => {
588
588
} ) ) ;
589
589
590
590
it ( 'should correctly handle the minimum spinner duration for multiple HTTP requests ran one after the others' , fakeAsync ( ( ) => {
591
- component . minDuration . set ( 2000 ) ;
591
+ fixture . componentRef . setInput ( 'minDuration' , 2000 ) ;
592
592
http . get ( '/fake' ) . subscribe ( ) ;
593
593
const firstRequest = httpMock . expectOne ( '/fake' ) ;
594
594
@@ -620,7 +620,7 @@ describe('NgHttpLoaderComponent', () => {
620
620
} ) ) ;
621
621
622
622
it ( 'should handle the extra spinner duration for multiple HTTP requests ran one after the others' , fakeAsync ( ( ) => {
623
- component . extraDuration . set ( 10 ) ;
623
+ fixture . componentRef . setInput ( 'extraDuration' , 10 ) ;
624
624
const runQuery$ = ( url : string ) : Observable < unknown > => http . get ( url ) ;
625
625
runQuery$ ( '/fake' ) . subscribe ( ) ;
626
626
const firstRequest = httpMock . expectOne ( '/fake' ) ;
@@ -648,7 +648,7 @@ describe('NgHttpLoaderComponent', () => {
648
648
} ) ) ;
649
649
650
650
it ( 'should still display the spinner when the minimum duration is inferior to the HTTP request duration' , fakeAsync ( ( ) => {
651
- component . minDuration . set ( 1000 ) ;
651
+ fixture . componentRef . setInput ( 'minDuration' , 1000 ) ;
652
652
http . get ( '/fake' ) . subscribe ( ) ;
653
653
654
654
// the HTTP request is pending for 1 second now
@@ -666,7 +666,7 @@ describe('NgHttpLoaderComponent', () => {
666
666
} ) ) ;
667
667
668
668
it ( 'should be possible to set the minimum duration without side effect on manual show/hide' , ( ) => {
669
- component . minDuration . set ( 10000 ) ;
669
+ fixture . componentRef . setInput ( 'minDuration' , 10000 ) ;
670
670
spinner . show ( ) ;
671
671
expect ( isVisible ) . toBeTruthy ( ) ;
672
672
@@ -675,7 +675,7 @@ describe('NgHttpLoaderComponent', () => {
675
675
} ) ;
676
676
677
677
it ( 'should be possible to set the extra duration without side effect on manual show/hide' , ( ) => {
678
- component . extraDuration . set ( 10000 ) ;
678
+ fixture . componentRef . setInput ( 'extraDuration' , 10000 ) ;
679
679
spinner . show ( ) ;
680
680
expect ( isVisible ) . toBeTruthy ( ) ;
681
681
@@ -685,8 +685,8 @@ describe('NgHttpLoaderComponent', () => {
685
685
686
686
it ( 'should be possible to mix debounce delay and minimum duration' , fakeAsync ( ( ) => {
687
687
// the spinner should not be visible the first second, then visible for 5 seconds
688
- component . minDuration . set ( 5000 ) ;
689
- component . debounceDelay . set ( 1000 ) ;
688
+ fixture . componentRef . setInput ( 'minDuration' , 5000 ) ;
689
+ fixture . componentRef . setInput ( 'debounceDelay' , 1000 ) ;
690
690
691
691
http . get ( '/fake' ) . subscribe ( ) ;
692
692
@@ -718,8 +718,8 @@ describe('NgHttpLoaderComponent', () => {
718
718
719
719
it ( 'should be possible to mix debounce delay and extra duration' , fakeAsync ( ( ) => {
720
720
// the spinner should not be visible the first second, then visible for 5 seconds
721
- component . extraDuration . set ( 5000 ) ;
722
- component . debounceDelay . set ( 1000 ) ;
721
+ fixture . componentRef . setInput ( 'extraDuration' , 5000 ) ;
722
+ fixture . componentRef . setInput ( 'debounceDelay' , 1000 ) ;
723
723
724
724
http . get ( '/fake' ) . subscribe ( ) ;
725
725
@@ -763,7 +763,7 @@ describe('NgHttpLoaderComponent', () => {
763
763
764
764
it ( 'should be possible to remove the backdrop CSS class' , ( ) => {
765
765
component . isVisible$ = of ( true ) ;
766
- component . backdrop . set ( false ) ;
766
+ fixture . componentRef . setInput ( 'backdrop' , false ) ;
767
767
fixture . detectChanges ( ) ;
768
768
769
769
const element = fixture
@@ -787,7 +787,7 @@ describe('NgHttpLoaderComponent', () => {
787
787
788
788
it ( 'should be possible to override opacity' , ( ) => {
789
789
component . isVisible$ = of ( true ) ;
790
- component . opacity . set ( '.3' ) ;
790
+ fixture . componentRef . setInput ( 'opacity' , '.3' ) ;
791
791
fixture . detectChanges ( ) ;
792
792
793
793
const element : HTMLElement = fixture
@@ -812,7 +812,7 @@ describe('NgHttpLoaderComponent', () => {
812
812
813
813
it ( 'should be possible to override backdrop background color when backdrop is true' , ( ) => {
814
814
component . isVisible$ = of ( true ) ;
815
- component . backdropBackgroundColor . set ( '#777777' ) ;
815
+ fixture . componentRef . setInput ( 'backdropBackgroundColor' , '#777777' ) ;
816
816
fixture . detectChanges ( ) ;
817
817
818
818
const element : HTMLElement = fixture
@@ -825,7 +825,7 @@ describe('NgHttpLoaderComponent', () => {
825
825
826
826
it ( 'should not have a transparent backdrop background color if backdrop is false' , ( ) => {
827
827
component . isVisible$ = of ( true ) ;
828
- component . backdrop . set ( false ) ;
828
+ fixture . componentRef . setInput ( 'backdrop' , false ) ;
829
829
fixture . detectChanges ( ) ;
830
830
831
831
const element : HTMLElement = fixture
0 commit comments