Skip to content

Commit

Permalink
perf(*): clean deprecated of angular libs
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jul 1, 2024
1 parent ec693ff commit 667740a
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 125 deletions.
3 changes: 1 addition & 2 deletions packages/abc/cell/cell.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserModule, By, DomSanitizer } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';

import { cleanCdkOverlayHtml, createTestContext } from '@delon/testing';
Expand All @@ -29,7 +28,7 @@ describe('abc: cell', () => {

const moduleAction = (): void => {
TestBed.configureTestingModule({
imports: [CellModule, NoopAnimationsModule, BrowserModule, RouterTestingModule.withRoutes([]), NzIconTestModule],
imports: [CellModule, NoopAnimationsModule, BrowserModule, NzIconTestModule],
declarations: [TestComponent, TestWidget]
});
};
Expand Down
9 changes: 5 additions & 4 deletions packages/abc/down-file/down-file.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable deprecation/deprecation */
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController, TestRequest } from '@angular/common/http/testing';
import { HttpHeaders, HttpResponse, provideHttpClient } from '@angular/common/http';
import { HttpTestingController, TestRequest, provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, DebugElement } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
Expand All @@ -27,8 +27,9 @@ describe('abc: down-file', () => {

function createComp(): void {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, DownFileModule],
declarations: [TestComponent]
imports: [DownFileModule],
declarations: [TestComponent],
providers: [provideHttpClient(), provideHttpClientTesting()]
});

fixture = TestBed.createComponent(TestComponent);
Expand Down
5 changes: 3 additions & 2 deletions packages/abc/exception/exception.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Directionality } from '@angular/cdk/bidi';
import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { provideRouter } from '@angular/router';

import { createTestContext } from '@delon/testing';
import { DelonLocaleModule, DelonLocaleService, en_US } from '@delon/theme';
Expand All @@ -17,7 +17,8 @@ describe('abc: exception', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ExceptionModule, DelonLocaleModule, RouterTestingModule],
imports: [ExceptionModule, DelonLocaleModule],
providers: [provideRouter([])],
declarations: [TestComponent]
});
({ fixture, dl, context } = createTestContext(TestComponent));
Expand Down
3 changes: 1 addition & 2 deletions packages/abc/full-content/full-content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement, ViewChild } from '@ang
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ActivationEnd, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { BehaviorSubject } from 'rxjs';

import { NzSafeAny } from 'ng-zorro-antd/core/types';
Expand All @@ -22,7 +21,7 @@ describe('abc: full-content', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [FullContentModule, RouterTestingModule.withRoutes([])],
imports: [FullContentModule],
declarations: [TestComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }]
Expand Down
6 changes: 3 additions & 3 deletions packages/abc/global-footer/global-footer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { APP_BASE_HREF } from '@angular/common';
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { provideRouter, Router } from '@angular/router';

import { WINDOW } from '@delon/util/token';

Expand Down Expand Up @@ -32,10 +31,11 @@ describe('abc: global-footer', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule.withRoutes([]), GlobalFooterModule],
imports: [GlobalFooterModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [TestComponent],
providers: [
provideRouter([]),
{ provide: APP_BASE_HREF, useValue: '/' },
{ provide: WINDOW, useFactory: () => new MockWindow() }
]
Expand Down
8 changes: 5 additions & 3 deletions packages/abc/notice-icon/notice-icon.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, discardPeriodicTasks, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
Expand All @@ -20,8 +21,9 @@ describe('abc: notice-icon', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, NoticeIconModule, HttpClientTestingModule, DelonLocaleModule],
declarations: [TestComponent]
imports: [NoopAnimationsModule, NoticeIconModule, DelonLocaleModule],
declarations: [TestComponent],
providers: [provideHttpClient(), provideHttpClientTesting()]
});
({ fixture, dl, context } = createTestContext(TestComponent));
});
Expand Down
6 changes: 3 additions & 3 deletions packages/abc/onboarding/onboarding.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { provideRouter, Router } from '@angular/router';
import { throwError } from 'rxjs';

import { createTestContext } from '@delon/testing';
Expand All @@ -20,7 +19,8 @@ describe('abc: onboarding', () => {

function genModule(): void {
TestBed.configureTestingModule({
imports: [OnboardingModule, NoopAnimationsModule, RouterTestingModule],
imports: [OnboardingModule, NoopAnimationsModule],
providers: [provideRouter([])],
declarations: [TestComponent]
});
({ fixture } = createTestContext(TestComponent));
Expand Down
23 changes: 11 additions & 12 deletions packages/abc/page-header/page-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { APP_BASE_HREF } from '@angular/common';
import { Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Router, provideRouter } from '@angular/router';

import { createTestContext } from '@delon/testing';
import {
Expand Down Expand Up @@ -36,12 +35,12 @@ describe('abc: page-header', () => {
let router: Router;

function genModule(other: { template?: string; providers?: NzSafeAny[]; created?: boolean }): void {
const imports = [
RouterTestingModule.withRoutes([{ path: '1-1/:name', component: TestComponent }]),
PageHeaderModule,
AlainThemeModule
const imports = [PageHeaderModule, AlainThemeModule];
const providers = [
provideRouter([{ path: '1-1/:name', component: TestComponent }]),
{ provide: APP_BASE_HREF, useValue: '/' },
SettingsService
];
const providers = [{ provide: APP_BASE_HREF, useValue: '/' }, SettingsService];
if (other.providers && other.providers.length) {
providers.push(...other.providers);
}
Expand Down Expand Up @@ -75,12 +74,12 @@ describe('abc: page-header', () => {
describe('', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([{ path: '1-1/:name', component: TestComponent }]),
PageHeaderModule,
AlainThemeModule
imports: [PageHeaderModule, AlainThemeModule],
providers: [
provideRouter([{ path: '1-1/:name', component: TestComponent }]),
{ provide: APP_BASE_HREF, useValue: '/' },
SettingsService
],
providers: [{ provide: APP_BASE_HREF, useValue: '/' }, SettingsService],
declarations: [TestComponent, TestAutoBreadcrumbComponent, TestI18nComponent]
});
});
Expand Down
5 changes: 2 additions & 3 deletions packages/abc/reuse-tab/reuse-tab.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Component, DebugElement, Injectable, TemplateRef, ViewChild } from '@an
import { ComponentFixture, discardPeriodicTasks, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ExtraOptions, RouteReuseStrategy, ROUTER_CONFIGURATION } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { ExtraOptions, RouteReuseStrategy, ROUTER_CONFIGURATION, RouterModule } from '@angular/router';
import { Observable, of } from 'rxjs';

import { ALAIN_I18N_TOKEN, DelonLocaleModule, DelonLocaleService, en_US, MenuService, zh_CN } from '@delon/theme';
Expand Down Expand Up @@ -47,7 +46,7 @@ describe('abc: reuse-tab', () => {
DelonLocaleModule,
ReuseTabComponent,
NoopAnimationsModule,
RouterTestingModule.withRoutes(
RouterModule.forRoot(
[
{
path: '',
Expand Down
10 changes: 6 additions & 4 deletions packages/abc/st/test/base.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { CommonModule } from '@angular/common';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, DebugElement, Injectable, TemplateRef, Type, ViewChild } from '@angular/core';
import { ComponentFixture, discardPeriodicTasks, flush, TestBed, tick } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { RouterModule } from '@angular/router';
import { Observable } from 'rxjs';

import { dispatchDropDown } from '@delon/testing';
Expand Down Expand Up @@ -102,14 +103,15 @@ export function genModule<T extends TestComponent>(
NoopAnimationsModule,
CommonModule,
FormsModule,
HttpClientTestingModule,
RouterTestingModule.withRoutes([]),
RouterModule.forRoot([]),
NzModalModule,
NzDrawerModule,
STModule,
DelonLocaleModule
];
const providers = [
provideHttpClient(),
provideHttpClientTesting(),
{
provide: ALAIN_I18N_TOKEN,
useClass: MockI18NServiceFake
Expand Down
8 changes: 5 additions & 3 deletions packages/abc/xlsx/xlsx.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { HttpClient, provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
Expand Down Expand Up @@ -29,9 +29,11 @@ describe('abc: xlsx', () => {
let srv: XlsxService;
function genModule(): void {
TestBed.configureTestingModule({
imports: [XlsxModule, HttpClientTestingModule],
imports: [XlsxModule],
declarations: [TestComponent],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
{ provide: HttpClient, useClass: MockHttpClient },
{ provide: LazyService, useClass: MockLazyService }
]
Expand Down
13 changes: 6 additions & 7 deletions packages/acl/src/acl-guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Router, provideRouter } from '@angular/router';
import { of } from 'rxjs';

import { ACLGuardService, aclCanActivate, aclCanActivateChild, aclCanMatch } from './acl-guard';
Expand All @@ -18,8 +17,8 @@ describe('acl: guard', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
imports: [
RouterTestingModule.withRoutes([
providers: [
provideRouter([
{ path: '403', component: TestComponent },
{
path: 'canActivate',
Expand All @@ -39,9 +38,9 @@ describe('acl: guard', () => {
canMatch: [aclCanMatch],
data: { guard: { role: ['admin'] } } as ACLGuardData
}
]),
DelonACLModule
]
])
],
imports: [DelonACLModule]
});
srv = TestBed.inject<ACLGuardService>(ACLGuardService);
acl = TestBed.inject<ACLService>(ACLService);
Expand Down
10 changes: 6 additions & 4 deletions packages/auth/src/social/social.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DOCUMENT } from '@angular/common';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { discardPeriodicTasks, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { DefaultUrlSerializer, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { DefaultUrlSerializer, Router, provideRouter } from '@angular/router';

import { DA_SERVICE_TOKEN, ITokenModel } from '../token/interface';
import { SimpleTokenModel } from '../token/simple/simple.model';
Expand Down Expand Up @@ -51,8 +51,10 @@ describe('auth: social.service', () => {

function genModule(tokenData?: SimpleTokenModel): void {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
providers: [
provideHttpClient(),
provideHttpClientTesting(),
provideRouter([]),
SocialService,
{ provide: DOCUMENT, useClass: MockDocument },
{ provide: Router, useValue: mockRouter }
Expand Down
12 changes: 3 additions & 9 deletions packages/auth/src/token/base.interceptor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DOCUMENT } from '@angular/common';
import { HttpClient, HttpContext, provideHttpClient, withInterceptors } from '@angular/common/http';
import {
HttpClientTestingModule,
HttpTestingController,
TestRequest,
provideHttpClientTesting
} from '@angular/common/http/testing';
import { HttpTestingController, TestRequest, provideHttpClientTesting } from '@angular/common/http/testing';
import { Type } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Router, provideRouter } from '@angular/router';
import { Observable } from 'rxjs';

import { AlainAuthConfig, provideAlainConfig } from '@delon/util/config';
Expand Down Expand Up @@ -67,8 +61,8 @@ describe('auth: base.interceptor', () => {

function genModule(options: AlainAuthConfig, tokenData?: ITokenModel, provider: any[] = []): void {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
providers: [
provideRouter([]),
{ provide: DOCUMENT, useValue: MockDoc },
provideHttpClient(withInterceptors([authSimpleInterceptor])),
provideHttpClientTesting(),
Expand Down
7 changes: 3 additions & 4 deletions packages/auth/src/token/jwt/jwt.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, NgModule } from '@angular/core';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Router, provideRouter } from '@angular/router';

import { DA_SERVICE_TOKEN, ITokenService } from '../interface';
import { authJWTCanActivate, authJWTCanActivateChild, authJWTCanMatch } from './jwt.guard';
Expand All @@ -13,8 +12,8 @@ describe('auth: JWTGuard', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MockComponent],
imports: [
RouterTestingModule.withRoutes([
providers: [
provideRouter([
{
path: 'home',
component: MockComponent,
Expand Down
10 changes: 4 additions & 6 deletions packages/auth/src/token/jwt/jwt.interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient, provideHttpClient, withInterceptors } from '@angular/common
import { HttpTestingController, TestRequest, provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, Type } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { provideRouter } from '@angular/router';
import { of, catchError } from 'rxjs';

import { AlainAuthConfig, provideAlainConfig } from '@delon/util/config';
Expand Down Expand Up @@ -30,15 +30,13 @@ describe('auth: jwt.interceptor', () => {
function genModule(options: AlainAuthConfig, tokenData?: JWTTokenModel): void {
TestBed.configureTestingModule({
declarations: [MockComponent],
imports: [
RouterTestingModule.withRoutes([
providers: [
provideRouter([
{
path: 'login',
component: MockComponent
}
])
],
providers: [
]),
provideHttpClient(withInterceptors([authJWTInterceptor])),
provideHttpClientTesting(),
provideAlainConfig({ auth: options }),
Expand Down
Loading

0 comments on commit 667740a

Please sign in to comment.