From b09f44020ff3caf658bd4339efcf571711ece63b Mon Sep 17 00:00:00 2001 From: Laffery <49607541+Laffery@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:36:29 +0800 Subject: [PATCH] refactor(module:descriptions): migrate demo to standalone mode (#8763) --- components/descriptions/demo/basic.ts | 4 +++ components/descriptions/demo/border.ts | 5 +++ components/descriptions/demo/custom-size.ts | 6 +++- components/descriptions/demo/module | 6 ---- components/descriptions/demo/responsive.ts | 4 +++ .../descriptions/demo/vertical-border.ts | 5 +++ components/descriptions/demo/vertical.ts | 4 +++ components/descriptions/descriptions.spec.ts | 33 +++++++------------ 8 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 components/descriptions/demo/module diff --git a/components/descriptions/demo/basic.ts b/components/descriptions/demo/basic.ts index 785d855918..3da7bc8508 100644 --- a/components/descriptions/demo/basic.ts +++ b/components/descriptions/demo/basic.ts @@ -1,7 +1,11 @@ import { Component } from '@angular/core'; +import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; + @Component({ selector: 'nz-demo-descriptions-basic', + standalone: true, + imports: [NzDescriptionsModule], template: ` Zhou Maomao diff --git a/components/descriptions/demo/border.ts b/components/descriptions/demo/border.ts index d7834b46eb..a12b2839eb 100644 --- a/components/descriptions/demo/border.ts +++ b/components/descriptions/demo/border.ts @@ -1,7 +1,12 @@ import { Component } from '@angular/core'; +import { NzBadgeModule } from 'ng-zorro-antd/badge'; +import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; + @Component({ selector: 'nz-demo-descriptions-border', + standalone: true, + imports: [NzBadgeModule, NzDescriptionsModule], template: ` Cloud Database diff --git a/components/descriptions/demo/custom-size.ts b/components/descriptions/demo/custom-size.ts index 670b124a81..6e86e63b8b 100644 --- a/components/descriptions/demo/custom-size.ts +++ b/components/descriptions/demo/custom-size.ts @@ -1,9 +1,13 @@ import { Component } from '@angular/core'; +import { FormsModule } from '@angular/forms'; -import { NzDescriptionsSize } from 'ng-zorro-antd/descriptions'; +import { NzDescriptionsModule, NzDescriptionsSize } from 'ng-zorro-antd/descriptions'; +import { NzRadioModule } from 'ng-zorro-antd/radio'; @Component({ selector: 'nz-demo-descriptions-custom-size', + standalone: true, + imports: [FormsModule, NzDescriptionsModule, NzRadioModule], template: ` diff --git a/components/descriptions/demo/module b/components/descriptions/demo/module deleted file mode 100644 index 9ba22fec20..0000000000 --- a/components/descriptions/demo/module +++ /dev/null @@ -1,6 +0,0 @@ -import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; -import { NzBadgeModule } from 'ng-zorro-antd/badge'; -import { NzRadioModule } from 'ng-zorro-antd/radio'; -import { NzButtonModule } from 'ng-zorro-antd/button'; - -export const moduleList = [ NzDescriptionsModule, NzBadgeModule, NzRadioModule, NzButtonModule ]; diff --git a/components/descriptions/demo/responsive.ts b/components/descriptions/demo/responsive.ts index 64904944d6..122adf606b 100644 --- a/components/descriptions/demo/responsive.ts +++ b/components/descriptions/demo/responsive.ts @@ -1,7 +1,11 @@ import { Component } from '@angular/core'; +import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; + @Component({ selector: 'nz-demo-descriptions-responsive', + standalone: true, + imports: [NzDescriptionsModule], template: ` Cloud Database diff --git a/components/descriptions/demo/vertical.ts b/components/descriptions/demo/vertical.ts index e3cec39b96..f812576f39 100644 --- a/components/descriptions/demo/vertical.ts +++ b/components/descriptions/demo/vertical.ts @@ -1,7 +1,11 @@ import { Component } from '@angular/core'; +import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; + @Component({ selector: 'nz-demo-descriptions-vertical', + standalone: true, + imports: [NzDescriptionsModule], template: ` Zhou Maomao diff --git a/components/descriptions/descriptions.spec.ts b/components/descriptions/descriptions.spec.ts index 175e2f971c..e57bf63b92 100644 --- a/components/descriptions/descriptions.spec.ts +++ b/components/descriptions/descriptions.spec.ts @@ -1,10 +1,8 @@ -import { BidiModule, Dir } from '@angular/cdk/bidi'; +import { BidiModule, Dir, Direction } from '@angular/cdk/bidi'; import { Component, ViewChild } from '@angular/core'; -import { ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { ComponentBed, createComponentBed } from 'ng-zorro-antd/core/testing/component-bed'; - import { NzDescriptionsComponent } from './descriptions.component'; import { NzDescriptionsModule } from './descriptions.module'; @@ -13,20 +11,15 @@ declare const viewport: any; describe('nz descriptions', () => { describe('with different spans', () => { - let testBed: ComponentBed; let testComponent: NzTestDescriptionsComponent; let componentElement: HTMLElement; let fixture: ComponentFixture; let rows; beforeEach(() => { - testBed = createComponentBed(NzTestDescriptionsComponent, { - imports: [NzDescriptionsModule] - }); - fixture = testBed.fixture; + fixture = TestBed.createComponent(NzTestDescriptionsComponent); testComponent = fixture.componentInstance; componentElement = fixture.debugElement.nativeElement; - fixture.detectChanges(); }); @@ -76,7 +69,7 @@ describe('nz descriptions', () => { rows = componentElement.querySelectorAll('.ant-descriptions-row'); const tds = componentElement.querySelectorAll('.ant-descriptions-item'); expect(rows.length).toBe(1); - expect((tds[1] as HTMLTableDataCellElement).colSpan).toBe(4); + expect((tds[1] as HTMLTableCellElement).colSpan).toBe(4); spyOnWarn.calls.reset(); }); @@ -126,17 +119,12 @@ describe('nz descriptions', () => { }); describe('RTL', () => { - let testBed: ComponentBed; let fixture: ComponentFixture; let componentElement: HTMLElement; beforeEach(() => { - testBed = createComponentBed(NzTestDescriptionsRtlComponent, { - declarations: [NzTestDescriptionsComponent], - imports: [NzDescriptionsModule, BidiModule] - }); - componentElement = testBed.debugElement.query(By.directive(NzDescriptionsComponent)).nativeElement; - fixture = testBed.fixture; + fixture = TestBed.createComponent(NzTestDescriptionsRtlComponent); + componentElement = fixture.debugElement.query(By.directive(NzDescriptionsComponent)).nativeElement; fixture.detectChanges(); }); @@ -150,7 +138,8 @@ describe('nz descriptions', () => { }); @Component({ - // eslint-disable-next-line + standalone: true, + imports: [NzDescriptionsModule], selector: 'nz-test-descriptions', template: ` @@ -163,12 +152,14 @@ describe('nz descriptions', () => { export class NzTestDescriptionsComponent { bordered = false; colspanArray: number[] = [1, 1, 1]; - column: number | { [key: string]: number } = 3; + column: NzDescriptionsComponent['nzColumn'] = 3; title = 'Title'; itemTitle = 'Item Title '; } @Component({ + standalone: true, + imports: [BidiModule, NzTestDescriptionsComponent], template: `
@@ -177,5 +168,5 @@ export class NzTestDescriptionsComponent { }) export class NzTestDescriptionsRtlComponent { @ViewChild(Dir) dir!: Dir; - direction = 'rtl'; + direction: Direction = 'rtl'; }