10
10
import { HttpClient , provideHttpClient , withInterceptors } from '@angular/common/http' ;
11
11
import { HttpTestingController , provideHttpClientTesting } from '@angular/common/http/testing' ;
12
12
import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
13
+ import { provideExperimentalZonelessChangeDetection , signal } from '@angular/core' ;
13
14
import { By } from '@angular/platform-browser' ;
14
15
import { forkJoin , Observable , of , Subscription } from 'rxjs' ;
15
16
import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component' ;
@@ -29,19 +30,20 @@ describe('NgHttpLoaderComponent', () => {
29
30
beforeEach ( async ( ) => {
30
31
await TestBed . configureTestingModule ( {
31
32
imports : [ NgHttpLoaderComponent ] ,
32
- providers : [ provideHttpClient ( withInterceptors ( [ pendingRequestsInterceptor$ ] ) ) , provideHttpClientTesting ( ) ]
33
+ providers : [
34
+ provideHttpClient ( withInterceptors ( [ pendingRequestsInterceptor$ ] ) ) ,
35
+ provideHttpClientTesting ( ) ,
36
+ provideExperimentalZonelessChangeDetection ( ) ,
37
+ ]
33
38
} )
34
39
. compileComponents ( ) ;
35
- } ) ;
36
40
37
- beforeEach ( ( ) => {
38
41
fixture = TestBed . createComponent ( NgHttpLoaderComponent ) ;
39
42
component = fixture . componentInstance ;
40
43
http = TestBed . inject ( HttpClient ) ;
41
44
httpMock = TestBed . inject ( HttpTestingController ) ;
42
45
spinner = TestBed . inject ( SpinnerVisibilityService ) ;
43
46
isVisible = false ;
44
- fixture . detectChanges ( ) ;
45
47
isVisibleSubscription = component . isVisible$ . subscribe ( v => isVisible = v ) ;
46
48
} ) ;
47
49
@@ -53,9 +55,9 @@ describe('NgHttpLoaderComponent', () => {
53
55
expect ( component ) . toBeTruthy ( ) ;
54
56
} ) ;
55
57
56
- it ( 'should create the ng-http-loader component with default values' , ( ) => {
57
- component . isVisible$ = of ( true ) ;
58
- fixture . detectChanges ( ) ;
58
+ it ( 'should create the ng-http-loader component with default values' , async ( ) => {
59
+ component . isVisible = signal ( true ) ;
60
+ await fixture . whenStable ( ) ;
59
61
60
62
const element = fixture
61
63
. debugElement
@@ -65,10 +67,10 @@ describe('NgHttpLoaderComponent', () => {
65
67
expect ( element . className ) . toBe ( 'sk-wave colored' ) ;
66
68
} ) ;
67
69
68
- it ( 'should not set the colored class if background-color is defined' , ( ) => {
69
- component . isVisible$ = of ( true ) ;
70
+ it ( 'should not set the colored class if background-color is defined' , async ( ) => {
71
+ component . isVisible = signal ( true ) ;
70
72
fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
71
- fixture . detectChanges ( ) ;
73
+ await fixture . whenStable ( ) ;
72
74
73
75
const element = fixture
74
76
. debugElement
@@ -86,10 +88,10 @@ describe('NgHttpLoaderComponent', () => {
86
88
expect ( element ) . toBeNull ( ) ;
87
89
} ) ;
88
90
89
- it ( 'should be able to specify another known spinner' , ( ) => {
90
- component . isVisible$ = of ( true ) ;
91
+ it ( 'should be able to specify another known spinner' , async ( ) => {
92
+ component . isVisible = signal ( true ) ;
91
93
component . spinner . set ( Spinkit . skRotatingPlane ) ;
92
- fixture . detectChanges ( ) ;
94
+ await fixture . whenStable ( ) ;
93
95
94
96
const element = fixture
95
97
. debugElement
@@ -99,10 +101,10 @@ describe('NgHttpLoaderComponent', () => {
99
101
expect ( element . className ) . toBe ( 'sk-rotating-plane colored-parent' ) ;
100
102
} ) ;
101
103
102
- it ( 'should allow us to specify a custom background-color' , ( ) => {
103
- component . isVisible$ = of ( true ) ;
104
+ it ( 'should allow us to specify a custom background-color' , async ( ) => {
105
+ component . isVisible = signal ( true ) ;
104
106
fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
105
- fixture . detectChanges ( ) ;
107
+ await fixture . whenStable ( ) ;
106
108
107
109
const element = fixture
108
110
. debugElement
@@ -749,9 +751,9 @@ describe('NgHttpLoaderComponent', () => {
749
751
expect ( isVisible ) . toBeFalsy ( ) ;
750
752
} ) ) ;
751
753
752
- it ( 'should set the backdrop CSS class by default' , ( ) => {
753
- component . isVisible$ = of ( true ) ;
754
- fixture . detectChanges ( ) ;
754
+ it ( 'should set the backdrop CSS class by default' , async ( ) => {
755
+ component . isVisible = signal ( true ) ;
756
+ await fixture . whenStable ( ) ;
755
757
756
758
const element = fixture
757
759
. debugElement
@@ -761,10 +763,10 @@ describe('NgHttpLoaderComponent', () => {
761
763
expect ( element ) . toBeTruthy ( ) ;
762
764
} ) ;
763
765
764
- it ( 'should be possible to remove the backdrop CSS class' , ( ) => {
766
+ it ( 'should be possible to remove the backdrop CSS class' , async ( ) => {
765
767
component . isVisible$ = of ( true ) ;
766
768
fixture . componentRef . setInput ( 'backdrop' , false ) ;
767
- fixture . detectChanges ( ) ;
769
+ await fixture . whenStable ( ) ;
768
770
769
771
const element = fixture
770
772
. debugElement
@@ -773,9 +775,9 @@ describe('NgHttpLoaderComponent', () => {
773
775
expect ( element ) . toBeNull ( ) ;
774
776
} ) ;
775
777
776
- it ( 'should have a default opacity' , ( ) => {
777
- component . isVisible$ = of ( true ) ;
778
- fixture . detectChanges ( ) ;
778
+ it ( 'should have a default opacity' , async ( ) => {
779
+ component . isVisible = signal ( true ) ;
780
+ await fixture . whenStable ( ) ;
779
781
780
782
const element : HTMLElement = fixture
781
783
. debugElement
@@ -785,10 +787,10 @@ describe('NgHttpLoaderComponent', () => {
785
787
expect ( element . style . opacity ) . toBe ( `0${ component . opacity ( ) } ` ) ;
786
788
} ) ;
787
789
788
- it ( 'should be possible to override opacity' , ( ) => {
789
- component . isVisible$ = of ( true ) ;
790
+ it ( 'should be possible to override opacity' , async ( ) => {
791
+ component . isVisible = signal ( true ) ;
790
792
fixture . componentRef . setInput ( 'opacity' , '.3' ) ;
791
- fixture . detectChanges ( ) ;
793
+ await fixture . whenStable ( ) ;
792
794
793
795
const element : HTMLElement = fixture
794
796
. debugElement
@@ -798,9 +800,9 @@ describe('NgHttpLoaderComponent', () => {
798
800
expect ( element . style . opacity ) . toBe ( `0${ component . opacity ( ) } ` ) ;
799
801
} ) ;
800
802
801
- it ( 'should have a default backdrop background color if backdrop is true' , ( ) => {
802
- component . isVisible$ = of ( true ) ;
803
- fixture . detectChanges ( ) ;
803
+ it ( 'should have a default backdrop background color if backdrop is true' , async ( ) => {
804
+ component . isVisible = signal ( true ) ;
805
+ await fixture . whenStable ( ) ;
804
806
805
807
const element : HTMLElement = fixture
806
808
. debugElement
@@ -810,10 +812,10 @@ describe('NgHttpLoaderComponent', () => {
810
812
expect ( element . style . backgroundColor ) . toBe ( 'rgb(241, 241, 241)' ) ;
811
813
} ) ;
812
814
813
- it ( 'should be possible to override backdrop background color when backdrop is true' , ( ) => {
814
- component . isVisible$ = of ( true ) ;
815
+ it ( 'should be possible to override backdrop background color when backdrop is true' , async ( ) => {
816
+ component . isVisible = signal ( true ) ;
815
817
fixture . componentRef . setInput ( 'backdropBackgroundColor' , '#777777' ) ;
816
- fixture . detectChanges ( ) ;
818
+ await fixture . whenStable ( ) ;
817
819
818
820
const element : HTMLElement = fixture
819
821
. debugElement
@@ -823,10 +825,10 @@ describe('NgHttpLoaderComponent', () => {
823
825
expect ( element . style . backgroundColor ) . toBe ( 'rgb(119, 119, 119)' ) ;
824
826
} ) ;
825
827
826
- it ( 'should not have a transparent backdrop background color if backdrop is false' , ( ) => {
827
- component . isVisible$ = of ( true ) ;
828
+ it ( 'should not have a transparent backdrop background color if backdrop is false' , async ( ) => {
829
+ component . isVisible = signal ( true ) ;
828
830
fixture . componentRef . setInput ( 'backdrop' , false ) ;
829
- fixture . detectChanges ( ) ;
831
+ await fixture . whenStable ( ) ;
830
832
831
833
const element : HTMLElement = fixture
832
834
. debugElement
0 commit comments