Skip to content

Commit

Permalink
chore: Handle HttpClientTestingModule deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalourdio committed Sep 10, 2024
1 parent 5fd2c0d commit 142d173
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/test/components/ng-http-loader.component.on-push.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
Expand All @@ -29,7 +29,8 @@ describe('NgHttpLoaderComponent OnPush', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [HostComponent],
imports: [HttpClientTestingModule, NgHttpLoaderModule.forRoot()]
imports: [NgHttpLoaderModule.forRoot()],
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
})
.compileComponents();
});
Expand Down
7 changes: 3 additions & 4 deletions src/test/components/ng-http-loader.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { forkJoin, Observable, of, Subscription } from 'rxjs';
Expand All @@ -29,8 +29,7 @@ describe('NgHttpLoaderComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [NgHttpLoaderComponent, ...SPINKIT_COMPONENTS],
imports: [HttpClientTestingModule],
providers: [PendingRequestsInterceptorProvider]
providers: [PendingRequestsInterceptorProvider, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
})
.compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

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

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [PendingRequestsInterceptorProvider]
providers: [PendingRequestsInterceptorProvider, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
});

pendingRequestsInterceptor = TestBed.inject(PendingRequestsInterceptor);
Expand Down

0 comments on commit 142d173

Please sign in to comment.