Skip to content

Commit 142d173

Browse files
committed
chore: Handle HttpClientTestingModule deprecation
1 parent 5fd2c0d commit 142d173

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { HttpClient } from '@angular/common/http';
11-
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
10+
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
1212
import { ChangeDetectionStrategy, Component } from '@angular/core';
1313
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
1414
import { By } from '@angular/platform-browser';
@@ -29,7 +29,8 @@ describe('NgHttpLoaderComponent OnPush', () => {
2929
beforeEach(async () => {
3030
await TestBed.configureTestingModule({
3131
declarations: [HostComponent],
32-
imports: [HttpClientTestingModule, NgHttpLoaderModule.forRoot()]
32+
imports: [NgHttpLoaderModule.forRoot()],
33+
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
3334
})
3435
.compileComponents();
3536
});

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { HttpClient } from '@angular/common/http';
11-
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
10+
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
1212
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
1313
import { By } from '@angular/platform-browser';
1414
import { forkJoin, Observable, of, Subscription } from 'rxjs';
@@ -29,8 +29,7 @@ describe('NgHttpLoaderComponent', () => {
2929
beforeEach(async () => {
3030
await TestBed.configureTestingModule({
3131
declarations: [NgHttpLoaderComponent, ...SPINKIT_COMPONENTS],
32-
imports: [HttpClientTestingModule],
33-
providers: [PendingRequestsInterceptorProvider]
32+
providers: [PendingRequestsInterceptorProvider, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
3433
})
3534
.compileComponents();
3635
});

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88
*/
99

10-
import { HttpClient, HttpResponse } from '@angular/common/http';
11-
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
10+
import { HttpClient, HttpResponse, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
1212
import { TestBed, waitForAsync } from '@angular/core/testing';
1313
import { forkJoin, Observable } from 'rxjs';
1414
import {
@@ -23,8 +23,7 @@ describe('PendingRequestsInterceptor', () => {
2323

2424
beforeEach(() => {
2525
TestBed.configureTestingModule({
26-
imports: [HttpClientTestingModule],
27-
providers: [PendingRequestsInterceptorProvider]
26+
providers: [PendingRequestsInterceptorProvider, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
2827
});
2928

3029
pendingRequestsInterceptor = TestBed.inject(PendingRequestsInterceptor);

0 commit comments

Comments
 (0)