From 6534fd39c25d8fe3938c77772a8e0d57f02b59ea Mon Sep 17 00:00:00 2001 From: Wendell Date: Tue, 25 Feb 2020 12:59:06 +0800 Subject: [PATCH] chore(module:result): refactor (#4724) --- components/result/nz-result.component.html | 45 ------------------- components/result/public-api.ts | 6 +-- .../{nz-result-cells.ts => result-cells.ts} | 0 ...esult.component.ts => result.component.ts} | 40 ++++++++++++++++- .../{nz-result.module.ts => result.module.ts} | 4 +- .../{nz-result.spec.ts => result.spec.ts} | 21 +++++---- 6 files changed, 54 insertions(+), 62 deletions(-) delete mode 100644 components/result/nz-result.component.html rename components/result/{nz-result-cells.ts => result-cells.ts} (100%) rename components/result/{nz-result.component.ts => result.component.ts} (58%) rename components/result/{nz-result.module.ts => result.module.ts} (93%) rename components/result/{nz-result.spec.ts => result.spec.ts} (86%) diff --git a/components/result/nz-result.component.html b/components/result/nz-result.component.html deleted file mode 100644 index 95f1cfd5694..00000000000 --- a/components/result/nz-result.component.html +++ /dev/null @@ -1,45 +0,0 @@ - -
- - - - - - - - - - - - - - - - -
- - - -
- {{ nzTitle }} -
-
- - - -
- {{ nzSubTitle }} -
-
- - - - - - -
- - {{ nzExtra }} - -
- diff --git a/components/result/public-api.ts b/components/result/public-api.ts index ce8a49bd444..f61a83bb243 100644 --- a/components/result/public-api.ts +++ b/components/result/public-api.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ -export * from './nz-result.module'; -export * from './nz-result.component'; -export * from './nz-result-cells'; +export * from './result.module'; +export * from './result.component'; +export * from './result-cells'; // Making these partial components not visible to users but comprehensible to ng-packagr. export { NzResultNotFoundComponent as ɵNzResultNotFoundComponent } from './partial/not-found'; diff --git a/components/result/nz-result-cells.ts b/components/result/result-cells.ts similarity index 100% rename from components/result/nz-result-cells.ts rename to components/result/result-cells.ts diff --git a/components/result/nz-result.component.ts b/components/result/result.component.ts similarity index 58% rename from components/result/nz-result.component.ts rename to components/result/result.component.ts index 2984097de04..3c121caa395 100644 --- a/components/result/nz-result.component.ts +++ b/components/result/result.component.ts @@ -26,8 +26,46 @@ const ExceptionStatus = ['404', '500', '403']; encapsulation: ViewEncapsulation.None, selector: 'nz-result', exportAs: 'nzResult', - templateUrl: './nz-result.component.html', providers: [NzUpdateHostClassService], + template: ` +
+ + + + + + + + +
+ +
+ {{ nzTitle }} +
+
+ + +
+ {{ nzSubTitle }} +
+
+ + +
+ + {{ nzExtra }} + +
+ + + + + + + + + + `, styles: [ ` nz-result { diff --git a/components/result/nz-result.module.ts b/components/result/result.module.ts similarity index 93% rename from components/result/nz-result.module.ts rename to components/result/result.module.ts index 4ac3754b77a..1999c9789b4 100644 --- a/components/result/nz-result.module.ts +++ b/components/result/result.module.ts @@ -18,8 +18,8 @@ import { NzResultIconDirective, NzResultSubtitleDirective, NzResultTitleDirective -} from './nz-result-cells'; -import { NzResultComponent } from './nz-result.component'; +} from './result-cells'; +import { NzResultComponent } from './result.component'; import { NzResultNotFoundComponent } from './partial/not-found'; import { NzResultServerErrorComponent } from './partial/server-error.component'; diff --git a/components/result/nz-result.spec.ts b/components/result/result.spec.ts similarity index 86% rename from components/result/nz-result.spec.ts rename to components/result/result.spec.ts index 1a2959b461e..d93987a80e6 100644 --- a/components/result/nz-result.spec.ts +++ b/components/result/result.spec.ts @@ -1,12 +1,12 @@ -import { CommonModule } from '@angular/common'; import { Component, DebugElement } from '@angular/core'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; +import { ComponentBed, createComponentBed } from 'ng-zorro-antd/core/testing/componet-bed'; import { NzIconModule } from 'ng-zorro-antd/icon'; -import { NzResultComponent } from './nz-result.component'; -import { NzResultModule } from './nz-result.module'; +import { NzResultComponent } from './result.component'; +import { NzResultModule } from './result.module'; @Component({ template: ` @@ -30,19 +30,18 @@ export class NzTestResultBasicComponent { } describe('nz-result', () => { + let testBed: ComponentBed; let fixture: ComponentFixture; let testComponent: NzTestResultBasicComponent; let resultEl: DebugElement; describe('basic', () => { beforeEach(() => { - TestBed.configureTestingModule({ - imports: [CommonModule, NzResultModule, NzIconModule], - declarations: [NzTestResultBasicComponent] - }).compileComponents(); - - fixture = TestBed.createComponent(NzTestResultBasicComponent); - testComponent = fixture.debugElement.componentInstance; + testBed = createComponentBed(NzTestResultBasicComponent, { + imports: [NzResultModule, NzIconModule] + }); + fixture = testBed.fixture; + testComponent = testBed.component; resultEl = fixture.debugElement.query(By.directive(NzResultComponent)); });