Skip to content

Commit

Permalink
[Angular] RouterTestingModule is deprecated since Angular 17.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Mar 25, 2024
1 parent cf8c1ba commit beeaf56
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const tsKeyId = this.generateTestEntityId(user.primaryKey.type);
_%>
import { TestBed } from '@angular/core/testing';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { RouterTestingHarness, RouterTestingModule } from '@angular/router/testing';
import { RouterTestingHarness } from '@angular/router/testing';
import { of } from 'rxjs';

import { Authority } from 'app/config/authority.constants';
Expand All @@ -32,7 +32,7 @@ import UserManagementDetailComponent from './user-management-detail.component';
describe('User Management Detail Component', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [UserManagementDetailComponent, RouterTestingModule.withRoutes([], { bindToComponentInputs: true })],
imports: [UserManagementDetailComponent],
providers: [
provideRouter(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { ComponentFixture, TestBed, waitForAsync, inject, fakeAsync, tick } from
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';

import { UserManagementService } from '../service/user-management.service';
Expand Down Expand Up @@ -53,7 +52,7 @@ describe('User Management Component', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([]), UserManagementComponent],
imports: [HttpClientTestingModule, UserManagementComponent],
providers: [{ provide: ActivatedRoute, useValue: { data, queryParamMap } }, AccountService],
})
.overrideTemplate(UserManagementComponent, '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
jest.mock('app/core/auth/state-storage.service');

import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
<%_ if (enableTranslation) { _%>
Expand Down Expand Up @@ -65,7 +64,6 @@ describe('Account Service', () => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
RouterTestingModule.withRoutes([]),
<%_ if (enableTranslation) { _%>
TranslateModule.forRoot(),
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const testEntity = this.generateTestEntityPrimaryKey(primaryKey, 0);
_%>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { RouterTestingHarness, RouterTestingModule } from '@angular/router/testing';
import { RouterTestingHarness } from '@angular/router/testing';
import { of } from 'rxjs';

<%_ if (anyFieldIsBlobDerived) { _%>
Expand All @@ -40,7 +40,7 @@ describe('<%= entityAngularName %> Management Detail Component', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [<%= entityAngularName %>DetailComponent, RouterTestingModule.withRoutes([], { bindToComponentInputs: true })],
imports: [<%= entityAngularName %>DetailComponent],
providers: [
provideRouter(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import {
of,
<%_ if (!readOnly) { _%>
Expand Down Expand Up @@ -60,7 +59,6 @@ describe('<%= entityAngularName %> Management Component', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([{ path: '<%= entityPage %>', component: <%= entityAngularName %>Component }]),
HttpClientTestingModule,
<%= entityAngularName %>Component,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { TestBed } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ActivatedRouteSnapshot, ActivatedRoute, Router, convertToParamMap } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';

import { I<%= entityAngularName %> } from '../<%= entityFileName %>.model';
Expand All @@ -39,7 +38,7 @@ describe('<%= entityAngularName %> routing resolve service', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
imports: [HttpClientTestingModule],
providers: [
{
provide: ActivatedRoute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { FormBuilder } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of, Subject, from } from 'rxjs';

import { <%= entityAngularName %>FormService } from './<%= entityFileName %>-form.service';
Expand Down Expand Up @@ -59,7 +58,6 @@ describe('<%= entityAngularName %> Management Update Component', () => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
RouterTestingModule.withRoutes([]),
<%= entityAngularName %>UpdateComponent,
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jest.mock('app/login/login.service');
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
<%_ if (!authenticationTypeOauth2) { _%>
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
<%_ } _%>
import { of<% if (!authenticationTypeOauth2) { %>, Subject<% } %> } from 'rxjs';

Expand Down Expand Up @@ -60,10 +59,7 @@ describe('Home Component', () => {
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
HomeComponent,
<%_ if (!authenticationTypeOauth2) { _%>
RouterTestingModule.withRoutes([]),
<%_ } _%>
HomeComponent
],
providers: [
AccountService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jest.mock('app/core/auth/account.service');
import { waitForAsync, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { Router, TitleStrategy } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { DOCUMENT } from '@angular/common';
import { Component } from '@angular/core';
import { of } from 'rxjs';
Expand Down Expand Up @@ -58,7 +57,6 @@ describe('MainComponent', () => {
imports: [
<%_ if (enableTranslation) { _%>
TranslateModule.forRoot(),
RouterTestingModule,
<%_ } _%>
MainComponent,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jest.mock('app/login/login.service');

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
<%_ if (enableTranslation) { _%>
import { TranslateModule } from '@ngx-translate/core';
Expand Down Expand Up @@ -56,7 +55,6 @@ describe('Navbar Component', () => {
imports: [
NavbarComponent,
HttpClientTestingModule,
RouterTestingModule.withRoutes([]),
<%_ if (enableTranslation) { _%>
TranslateModule.forRoot(),
<%_ } _%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { ElementRef } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { Router, Navigation } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of, throwError } from 'rxjs';

import { AccountService } from 'app/core/auth/account.service';
Expand All @@ -41,7 +40,7 @@ describe('LoginComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([]), LoginComponent],
imports: [LoginComponent],
providers: [
FormBuilder,
AccountService,
Expand Down

0 comments on commit beeaf56

Please sign in to comment.