1010import { HttpClient , provideHttpClient , withInterceptors } from '@angular/common/http' ;
1111import { HttpTestingController , provideHttpClientTesting } from '@angular/common/http/testing' ;
1212import { ComponentFixture , fakeAsync , TestBed , tick , waitForAsync } from '@angular/core/testing' ;
13+ import { provideExperimentalZonelessChangeDetection , signal } from '@angular/core' ;
1314import { By } from '@angular/platform-browser' ;
1415import { forkJoin , Observable , of , Subscription } from 'rxjs' ;
1516import { NgHttpLoaderComponent } from '../../lib/components/ng-http-loader.component' ;
@@ -29,19 +30,20 @@ describe('NgHttpLoaderComponent', () => {
2930 beforeEach ( async ( ) => {
3031 await TestBed . configureTestingModule ( {
3132 imports : [ NgHttpLoaderComponent ] ,
32- providers : [ provideHttpClient ( withInterceptors ( [ pendingRequestsInterceptor$ ] ) ) , provideHttpClientTesting ( ) ]
33+ providers : [
34+ provideHttpClient ( withInterceptors ( [ pendingRequestsInterceptor$ ] ) ) ,
35+ provideHttpClientTesting ( ) ,
36+ provideExperimentalZonelessChangeDetection ( ) ,
37+ ]
3338 } )
3439 . compileComponents ( ) ;
35- } ) ;
3640
37- beforeEach ( ( ) => {
3841 fixture = TestBed . createComponent ( NgHttpLoaderComponent ) ;
3942 component = fixture . componentInstance ;
4043 http = TestBed . inject ( HttpClient ) ;
4144 httpMock = TestBed . inject ( HttpTestingController ) ;
4245 spinner = TestBed . inject ( SpinnerVisibilityService ) ;
4346 isVisible = false ;
44- fixture . detectChanges ( ) ;
4547 isVisibleSubscription = component . isVisible$ . subscribe ( v => isVisible = v ) ;
4648 } ) ;
4749
@@ -53,9 +55,9 @@ describe('NgHttpLoaderComponent', () => {
5355 expect ( component ) . toBeTruthy ( ) ;
5456 } ) ;
5557
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 ( ) ;
5961
6062 const element = fixture
6163 . debugElement
@@ -65,10 +67,10 @@ describe('NgHttpLoaderComponent', () => {
6567 expect ( element . className ) . toBe ( 'sk-wave colored' ) ;
6668 } ) ;
6769
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 ) ;
7072 fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
71- fixture . detectChanges ( ) ;
73+ await fixture . whenStable ( ) ;
7274
7375 const element = fixture
7476 . debugElement
@@ -86,10 +88,10 @@ describe('NgHttpLoaderComponent', () => {
8688 expect ( element ) . toBeNull ( ) ;
8789 } ) ;
8890
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 ) ;
9193 component . spinner . set ( Spinkit . skRotatingPlane ) ;
92- fixture . detectChanges ( ) ;
94+ await fixture . whenStable ( ) ;
9395
9496 const element = fixture
9597 . debugElement
@@ -99,10 +101,10 @@ describe('NgHttpLoaderComponent', () => {
99101 expect ( element . className ) . toBe ( 'sk-rotating-plane colored-parent' ) ;
100102 } ) ;
101103
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 ) ;
104106 fixture . componentRef . setInput ( 'backgroundColor' , '#ff0000' ) ;
105- fixture . detectChanges ( ) ;
107+ await fixture . whenStable ( ) ;
106108
107109 const element = fixture
108110 . debugElement
@@ -749,9 +751,9 @@ describe('NgHttpLoaderComponent', () => {
749751 expect ( isVisible ) . toBeFalsy ( ) ;
750752 } ) ) ;
751753
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 ( ) ;
755757
756758 const element = fixture
757759 . debugElement
@@ -761,10 +763,10 @@ describe('NgHttpLoaderComponent', () => {
761763 expect ( element ) . toBeTruthy ( ) ;
762764 } ) ;
763765
764- it ( 'should be possible to remove the backdrop CSS class' , ( ) => {
766+ it ( 'should be possible to remove the backdrop CSS class' , async ( ) => {
765767 component . isVisible$ = of ( true ) ;
766768 fixture . componentRef . setInput ( 'backdrop' , false ) ;
767- fixture . detectChanges ( ) ;
769+ await fixture . whenStable ( ) ;
768770
769771 const element = fixture
770772 . debugElement
@@ -773,9 +775,9 @@ describe('NgHttpLoaderComponent', () => {
773775 expect ( element ) . toBeNull ( ) ;
774776 } ) ;
775777
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 ( ) ;
779781
780782 const element : HTMLElement = fixture
781783 . debugElement
@@ -785,10 +787,10 @@ describe('NgHttpLoaderComponent', () => {
785787 expect ( element . style . opacity ) . toBe ( `0${ component . opacity ( ) } ` ) ;
786788 } ) ;
787789
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 ) ;
790792 fixture . componentRef . setInput ( 'opacity' , '.3' ) ;
791- fixture . detectChanges ( ) ;
793+ await fixture . whenStable ( ) ;
792794
793795 const element : HTMLElement = fixture
794796 . debugElement
@@ -798,9 +800,9 @@ describe('NgHttpLoaderComponent', () => {
798800 expect ( element . style . opacity ) . toBe ( `0${ component . opacity ( ) } ` ) ;
799801 } ) ;
800802
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 ( ) ;
804806
805807 const element : HTMLElement = fixture
806808 . debugElement
@@ -810,10 +812,10 @@ describe('NgHttpLoaderComponent', () => {
810812 expect ( element . style . backgroundColor ) . toBe ( 'rgb(241, 241, 241)' ) ;
811813 } ) ;
812814
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 ) ;
815817 fixture . componentRef . setInput ( 'backdropBackgroundColor' , '#777777' ) ;
816- fixture . detectChanges ( ) ;
818+ await fixture . whenStable ( ) ;
817819
818820 const element : HTMLElement = fixture
819821 . debugElement
@@ -823,10 +825,10 @@ describe('NgHttpLoaderComponent', () => {
823825 expect ( element . style . backgroundColor ) . toBe ( 'rgb(119, 119, 119)' ) ;
824826 } ) ;
825827
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 ) ;
828830 fixture . componentRef . setInput ( 'backdrop' , false ) ;
829- fixture . detectChanges ( ) ;
831+ await fixture . whenStable ( ) ;
830832
831833 const element : HTMLElement = fixture
832834 . debugElement
0 commit comments