From 9d533cf7841f25d47d3781e8a591d2cb77869776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=89=B2?= Date: Wed, 19 Dec 2018 16:57:23 +0800 Subject: [PATCH] feat(module:testing): add @delon/testing lib (#329) --- packages/abc/avatar-list/package.json | 2 +- packages/abc/date-picker/package.json | 2 +- packages/abc/down-file/package.json | 2 +- packages/abc/edit/package.json | 2 +- packages/abc/ellipsis/package.json | 2 +- packages/abc/error-collect/package.json | 2 +- packages/abc/exception/package.json | 2 +- packages/abc/ng-package.json | 2 +- packages/abc/notice-icon/package.json | 2 +- packages/abc/page-header/package.json | 2 +- packages/abc/reuse-tab/package.json | 2 +- packages/abc/sidebar-nav/package.json | 2 +- packages/abc/table/package.json | 2 +- packages/chart/bar/bar.spec.ts | 2 +- packages/chart/card/package.json | 2 +- packages/chart/gauge/gauge.spec.ts | 2 +- packages/chart/mini-area/mini-area.spec.ts | 2 +- packages/chart/mini-bar/mini-bar.spec.ts | 2 +- .../chart/mini-progress/mini-progress.spec.ts | 2 +- packages/chart/mini-progress/package.json | 2 +- packages/chart/ng-package.json | 2 +- packages/chart/pie/package.json | 2 +- packages/chart/pie/pie.spec.ts | 2 +- packages/chart/radar/package.json | 2 +- packages/chart/radar/radar.spec.ts | 2 +- packages/chart/single-bar/single-bar.spec.ts | 2 +- packages/chart/tag-cloud/tag-cloud.spec.ts | 2 +- packages/chart/timeline/timeline.spec.ts | 2 +- packages/chart/water-wave/water-wave.spec.ts | 2 +- packages/form/ng-package.json | 2 +- packages/testing/README.md | 20 ++++++++ packages/testing/index.ts | 8 ---- packages/testing/ng-package.json | 12 +++++ packages/testing/package.json | 21 +++++++++ packages/testing/public_api.ts | 19 +++----- packages/testing/{ => src}/dispatch-events.ts | 0 packages/testing/{ => src}/event-objects.ts | 0 packages/testing/{ => src}/g2.ts | 0 packages/testing/{ => src}/suite.ts | 46 ++++++++----------- packages/testing/{ => src}/type-in-element.ts | 0 packages/testing/{ => src}/zorro.ts | 7 ++- packages/testing/tsconfig.lib.json | 16 +++++++ packages/theme/ng-package.json | 2 +- packages/util/ng-package.json | 2 +- scripts/ci/build-lib.sh | 3 +- 45 files changed, 135 insertions(+), 81 deletions(-) create mode 100644 packages/testing/README.md create mode 100644 packages/testing/ng-package.json create mode 100644 packages/testing/package.json rename packages/testing/{ => src}/dispatch-events.ts (100%) rename packages/testing/{ => src}/event-objects.ts (100%) rename packages/testing/{ => src}/g2.ts (100%) rename packages/testing/{ => src}/suite.ts (72%) rename packages/testing/{ => src}/type-in-element.ts (100%) rename packages/testing/{ => src}/zorro.ts (79%) create mode 100644 packages/testing/tsconfig.lib.json diff --git a/packages/abc/avatar-list/package.json b/packages/abc/avatar-list/package.json index a90d33ae6..dcaac6ec8 100644 --- a/packages/abc/avatar-list/package.json +++ b/packages/abc/avatar-list/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "avatarList", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd" + "ng-zorro-antd": "ng-zorro-antd" } } } diff --git a/packages/abc/date-picker/package.json b/packages/abc/date-picker/package.json index 765c0e621..c2aa9c6ec 100644 --- a/packages/abc/date-picker/package.json +++ b/packages/abc/date-picker/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "datePicker", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/abc/down-file/package.json b/packages/abc/down-file/package.json index 51685b4c3..cfa1ffcae 100644 --- a/packages/abc/down-file/package.json +++ b/packages/abc/down-file/package.json @@ -5,7 +5,7 @@ "entryFile": "public_api.ts", "umdModuleIds": { "file-saver": "saveAs", - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme" } } diff --git a/packages/abc/edit/package.json b/packages/abc/edit/package.json index 8243b0b08..367f2f7c7 100644 --- a/packages/abc/edit/package.json +++ b/packages/abc/edit/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "edit", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/abc/ellipsis/package.json b/packages/abc/ellipsis/package.json index 5334dbe7b..f5762a10c 100644 --- a/packages/abc/ellipsis/package.json +++ b/packages/abc/ellipsis/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "ellipsis", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/abc/error-collect/package.json b/packages/abc/error-collect/package.json index c3c1fe0c3..255216cac 100644 --- a/packages/abc/error-collect/package.json +++ b/packages/abc/error-collect/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "errorCollect", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/abc/exception/package.json b/packages/abc/exception/package.json index f200d51f2..aa1a2cb66 100644 --- a/packages/abc/exception/package.json +++ b/packages/abc/exception/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "exception", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/abc/ng-package.json b/packages/abc/ng-package.json index fb8b605c4..0b49d461f 100644 --- a/packages/abc/ng-package.json +++ b/packages/abc/ng-package.json @@ -5,7 +5,7 @@ "flatModuleFile": "abc", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "date-fns": "DateFns", "qrious": "Qrious", "file-saver": "saveAs", diff --git a/packages/abc/notice-icon/package.json b/packages/abc/notice-icon/package.json index 3c9740b5a..f1044d5fb 100644 --- a/packages/abc/notice-icon/package.json +++ b/packages/abc/notice-icon/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "noticeIcon", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/abc/page-header/package.json b/packages/abc/page-header/package.json index 70e858c12..846baab07 100644 --- a/packages/abc/page-header/package.json +++ b/packages/abc/page-header/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "pageHeader", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/abc/reuse-tab": "delon.abc.reuseTab", "@delon/theme": "delon.theme", "@delon/util": "delon.util" diff --git a/packages/abc/reuse-tab/package.json b/packages/abc/reuse-tab/package.json index f048b0ae6..caecff576 100644 --- a/packages/abc/reuse-tab/package.json +++ b/packages/abc/reuse-tab/package.json @@ -6,7 +6,7 @@ "umdModuleIds": { "@angular/cdk/overlay": "ng.cdk.overlay", "@angular/cdk/portal": "ng.cdk.portal", - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/abc/sidebar-nav/package.json b/packages/abc/sidebar-nav/package.json index 44b3c5efe..5327265a3 100644 --- a/packages/abc/sidebar-nav/package.json +++ b/packages/abc/sidebar-nav/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "sidebarNav", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/abc/table/package.json b/packages/abc/table/package.json index 97ee1ec67..14b0893c0 100644 --- a/packages/abc/table/package.json +++ b/packages/abc/table/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "table", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/abc/xlsx": "delon.abc.xlsx", "@delon/theme": "delon.theme", "@delon/acl": "delon.acl", diff --git a/packages/chart/bar/bar.spec.ts b/packages/chart/bar/bar.spec.ts index 76ab3e416..93048ac9b 100644 --- a/packages/chart/bar/bar.spec.ts +++ b/packages/chart/bar/bar.spec.ts @@ -1,6 +1,6 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2BarComponent } from './bar.component'; import { G2BarModule } from './bar.module'; diff --git a/packages/chart/card/package.json b/packages/chart/card/package.json index 6442f4426..c0475c198 100644 --- a/packages/chart/card/package.json +++ b/packages/chart/card/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "card", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/chart/gauge/gauge.spec.ts b/packages/chart/gauge/gauge.spec.ts index 949f556ce..10d3e347e 100644 --- a/packages/chart/gauge/gauge.spec.ts +++ b/packages/chart/gauge/gauge.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2GaugeComponent } from './gauge.component'; import { G2GaugeModule } from './gauge.module'; diff --git a/packages/chart/mini-area/mini-area.spec.ts b/packages/chart/mini-area/mini-area.spec.ts index d41043bdb..22d99bc45 100644 --- a/packages/chart/mini-area/mini-area.spec.ts +++ b/packages/chart/mini-area/mini-area.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2MiniAreaComponent } from './mini-area.component'; import { G2MiniAreaModule } from './mini-area.module'; diff --git a/packages/chart/mini-bar/mini-bar.spec.ts b/packages/chart/mini-bar/mini-bar.spec.ts index 1973665e2..5ccea855b 100644 --- a/packages/chart/mini-bar/mini-bar.spec.ts +++ b/packages/chart/mini-bar/mini-bar.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2MiniBarComponent } from './mini-bar.component'; import { G2MiniBarModule } from './mini-bar.module'; diff --git a/packages/chart/mini-progress/mini-progress.spec.ts b/packages/chart/mini-progress/mini-progress.spec.ts index 7a060cb76..556e64e6b 100644 --- a/packages/chart/mini-progress/mini-progress.spec.ts +++ b/packages/chart/mini-progress/mini-progress.spec.ts @@ -1,6 +1,6 @@ import { Component, DebugElement, ViewChild } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2MiniProgressComponent } from './mini-progress.component'; import { G2MiniProgressModule } from './mini-progress.module'; diff --git a/packages/chart/mini-progress/package.json b/packages/chart/mini-progress/package.json index 818bf2487..57583d3d3 100644 --- a/packages/chart/mini-progress/package.json +++ b/packages/chart/mini-progress/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "mini-progress", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/chart/ng-package.json b/packages/chart/ng-package.json index 529d964be..0deee9554 100644 --- a/packages/chart/ng-package.json +++ b/packages/chart/ng-package.json @@ -6,7 +6,7 @@ "flatModuleFile": "chart", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/chart/pie/package.json b/packages/chart/pie/package.json index 960efd041..61c8e4041 100644 --- a/packages/chart/pie/package.json +++ b/packages/chart/pie/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "pie", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/chart/pie/pie.spec.ts b/packages/chart/pie/pie.spec.ts index dbfc9b20b..191f60602 100644 --- a/packages/chart/pie/pie.spec.ts +++ b/packages/chart/pie/pie.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync, tick } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2PieComponent } from './pie.component'; import { G2PieModule } from './pie.module'; diff --git a/packages/chart/radar/package.json b/packages/chart/radar/package.json index 56bef3518..e9c2656c7 100644 --- a/packages/chart/radar/package.json +++ b/packages/chart/radar/package.json @@ -4,7 +4,7 @@ "flatModuleFile": "radar", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/util": "delon.util" } } diff --git a/packages/chart/radar/radar.spec.ts b/packages/chart/radar/radar.spec.ts index ee0afa300..bc5fe3123 100644 --- a/packages/chart/radar/radar.spec.ts +++ b/packages/chart/radar/radar.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2RadarComponent, G2RadarData } from './radar.component'; import { G2RadarModule } from './radar.module'; diff --git a/packages/chart/single-bar/single-bar.spec.ts b/packages/chart/single-bar/single-bar.spec.ts index a7d9d3a00..a8f4c62d1 100644 --- a/packages/chart/single-bar/single-bar.spec.ts +++ b/packages/chart/single-bar/single-bar.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2SingleBarComponent } from './single-bar.component'; import { G2SingleBarModule } from './single-bar.module'; diff --git a/packages/chart/tag-cloud/tag-cloud.spec.ts b/packages/chart/tag-cloud/tag-cloud.spec.ts index c89fbf241..e4778f1e4 100644 --- a/packages/chart/tag-cloud/tag-cloud.spec.ts +++ b/packages/chart/tag-cloud/tag-cloud.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2TagCloudComponent, G2TagCloudData } from './tag-cloud.component'; import { G2TagCloudModule } from './tag-cloud.module'; diff --git a/packages/chart/timeline/timeline.spec.ts b/packages/chart/timeline/timeline.spec.ts index 4ca2dde95..f8177fd01 100644 --- a/packages/chart/timeline/timeline.spec.ts +++ b/packages/chart/timeline/timeline.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2TimelineComponent, G2TimelineData } from './timeline.component'; import { G2TimelineModule } from './timeline.module'; diff --git a/packages/chart/water-wave/water-wave.spec.ts b/packages/chart/water-wave/water-wave.spec.ts index 2ef98daff..7ba9d2455 100644 --- a/packages/chart/water-wave/water-wave.spec.ts +++ b/packages/chart/water-wave/water-wave.spec.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core'; import { fakeAsync } from '@angular/core/testing'; -import { PageG2 } from '../../testing/g2'; +import { PageG2 } from '@delon/testing'; import { G2WaterWaveComponent } from './water-wave.component'; import { G2WaterWaveModule } from './water-wave.module'; diff --git a/packages/form/ng-package.json b/packages/form/ng-package.json index f3b88221b..ab1b33155 100644 --- a/packages/form/ng-package.json +++ b/packages/form/ng-package.json @@ -6,7 +6,7 @@ "flatModuleFile": "form", "entryFile": "public_api.ts", "umdModuleIds": { - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "@delon/theme": "delon.theme", "@delon/util": "delon.util" } diff --git a/packages/testing/README.md b/packages/testing/README.md new file mode 100644 index 000000000..dbcd5df53 --- /dev/null +++ b/packages/testing/README.md @@ -0,0 +1,20 @@ +# @delon/testing module [![Build Status](https://travis-ci.org/ng-alain/delon.svg?branch=master)](https://travis-ci.org/ng-alain/delon) [![NPM version](https://img.shields.io/npm/v/@delon/testing.svg)](https://www.npmjs.com/package/@delon/testing) [![NPM version](https://img.shields.io/npm/v/@delon/testing/next.svg)](https://www.npmjs.com/package/@delon/testing) [![Taobao version](https://npm.taobao.org/badge/v/@delon/testing.svg?style=flat-square)](https://npm.taobao.org/package/@delon/testing) + +Test suite for ng-alain. + +## Architecture + +![Architecture](https://raw.githubusercontent.com/ng-alain/delon/master/_screenshot/architecture.png) + +## Troubleshooting + +Please follow this guidelines when reporting bugs and feature requests: + +1. Use [GitHub Issues](https://github.com/ng-alain/delon/issues) board to report bugs and feature requests (not our email address) +2. Please **always** write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it. + +Thanks for understanding! + +### License + +The MIT License (see the [LICENSE](https://github.com/ng-alain/delon/blob/master/LICENSE) file for the full text) diff --git a/packages/testing/index.ts b/packages/testing/index.ts index 2dc5054f8..4aaf8f92e 100644 --- a/packages/testing/index.ts +++ b/packages/testing/index.ts @@ -1,9 +1 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ - export * from './public_api'; diff --git a/packages/testing/ng-package.json b/packages/testing/ng-package.json new file mode 100644 index 000000000..39d4909c2 --- /dev/null +++ b/packages/testing/ng-package.json @@ -0,0 +1,12 @@ +{ + "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../dist/@delon/testing", + "deleteDestPath": true, + "lib": { + "flatModuleFile": "testing", + "entryFile": "public_api.ts", + "umdModuleIds": { + "ng-zorro-antd": "ng-zorro-antd" + } + } +} diff --git a/packages/testing/package.json b/packages/testing/package.json new file mode 100644 index 000000000..77e548a25 --- /dev/null +++ b/packages/testing/package.json @@ -0,0 +1,21 @@ +{ + "name": "@delon/testing", + "version": "0.0.0-PLACEHOLDER", + "author": "cipchk", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/ng-alain/delon.git" + }, + "bugs": { + "url": "https://github.com/ng-alain/ng-alain/issues" + }, + "homepage": "https://ng-alain.com", + "keywords": [ + "delon", + "ng-alain", + "angular", + "testing" + ], + "sideEffects": false +} diff --git a/packages/testing/public_api.ts b/packages/testing/public_api.ts index d2fab874b..36f0f0f84 100644 --- a/packages/testing/public_api.ts +++ b/packages/testing/public_api.ts @@ -1,13 +1,8 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ +// from angular +export * from './src/dispatch-events'; +export * from './src/event-objects'; +export * from './src/type-in-element'; -export * from './dispatch-events'; -export * from './event-objects'; -export * from './type-in-element'; -export * from './zorro'; -export * from './suite'; +export * from './src/zorro'; +export * from './src/g2'; +export * from './src/suite'; diff --git a/packages/testing/dispatch-events.ts b/packages/testing/src/dispatch-events.ts similarity index 100% rename from packages/testing/dispatch-events.ts rename to packages/testing/src/dispatch-events.ts diff --git a/packages/testing/event-objects.ts b/packages/testing/src/event-objects.ts similarity index 100% rename from packages/testing/event-objects.ts rename to packages/testing/src/event-objects.ts diff --git a/packages/testing/g2.ts b/packages/testing/src/g2.ts similarity index 100% rename from packages/testing/g2.ts rename to packages/testing/src/g2.ts diff --git a/packages/testing/suite.ts b/packages/testing/src/suite.ts similarity index 72% rename from packages/testing/suite.ts rename to packages/testing/src/suite.ts index 3d07abdeb..9c868d366 100644 --- a/packages/testing/suite.ts +++ b/packages/testing/src/suite.ts @@ -1,6 +1,24 @@ import { Type } from '@angular/core'; import { getTestBed, ComponentFixture, TestBed } from '@angular/core/testing'; +export class TestContext { + constructor(public fixture: ComponentFixture) { } + + get component() { return this.fixture.componentInstance; } + + get el(): HTMLElement { return this.fixture.debugElement.nativeElement; } + + get dl() { return this.fixture.debugElement; } + + get context() { return this.fixture.componentInstance; } + + detectChanges() { this.fixture.detectChanges(); } + + resolve(component: Type) { + return this.fixture.debugElement.injector.get(component) as T1; + } +} + export const configureTestSuite = (configureAction?: () => void) => { const testBedApi: any = getTestBed(); const originReset = TestBed.resetTestingModule; @@ -28,32 +46,6 @@ export const configureTestSuite = (configureAction?: () => void) => { }); }; -export class TestCtx { - constructor(public fixture: ComponentFixture) { } - - get component() { return this.fixture.componentInstance; } - - get el(): HTMLElement { return this.fixture.debugElement.nativeElement; } - - get dl() { return this.fixture.debugElement; } - - get context() { return this.fixture.componentInstance; } - - detectChanges() { this.fixture.detectChanges(); } - - resolve(component: Type) { return this.fixture.debugElement.injector.get(component); } -} - export const createTestContext = (component: Type) => { - const fixture = TestBed.createComponent(component); - const testCtx = new TestCtx(fixture); - return testCtx; -}; - -export const createStableTestContext = async (component: Type) => { - const testCtx = createTestContext(component); - testCtx.detectChanges(); - await testCtx.fixture.whenStable(); - testCtx.detectChanges(); - return testCtx; + return new TestContext(TestBed.createComponent(component)); }; diff --git a/packages/testing/type-in-element.ts b/packages/testing/src/type-in-element.ts similarity index 100% rename from packages/testing/type-in-element.ts rename to packages/testing/src/type-in-element.ts diff --git a/packages/testing/zorro.ts b/packages/testing/src/zorro.ts similarity index 79% rename from packages/testing/zorro.ts rename to packages/testing/src/zorro.ts index c86f9493e..ce064a9e3 100644 --- a/packages/testing/zorro.ts +++ b/packages/testing/src/zorro.ts @@ -4,9 +4,14 @@ import { By } from '@angular/platform-browser'; import { NzDropDownDirective } from 'ng-zorro-antd'; -// https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/dropdown/nz-dropdown.component.ts#L159 +/** + * [nz-dropdown](https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/dropdown/nz-dropdown.component.ts#L159) 抖动合理值 + */ export const DROPDOWN_MIN_TIME = 51; +/** + * 触发 dropdown + */ export function dispatchDropDown(dl: DebugElement, trigger: 'mouseleave' | 'click', allowNull = true) { const directive = dl.query(By.directive(NzDropDownDirective)); if (allowNull && directive == null) { diff --git a/packages/testing/tsconfig.lib.json b/packages/testing/tsconfig.lib.json new file mode 100644 index 000000000..d6636f9dc --- /dev/null +++ b/packages/testing/tsconfig.lib.json @@ -0,0 +1,16 @@ +{ + "extends": "../tsconfig.lib.json", + "compilerOptions": { + "baseUrl": ".", + "rootDir": ".", + "typeRoots": ["../../node_modules/@types"], + "paths": { + "@delon/*": ["../../dist/@delon/*"] + } + }, + "angularCompilerOptions": { + "annotateForClosureCompiler": true, + "strictMetadataEmit": false, + "skipTemplateCodegen": true + } +} diff --git a/packages/theme/ng-package.json b/packages/theme/ng-package.json index a37286e8c..e1a13ae1e 100644 --- a/packages/theme/ng-package.json +++ b/packages/theme/ng-package.json @@ -8,7 +8,7 @@ "umdModuleIds": { "@angular/cdk/overlay": "ng.cdk.overlay", "@angular/cdk/portal": "ng.cdk.portal", - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "date-fns": "DateFns", "@delon/acl": "delon.acl", "@delon/util": "delon.util" diff --git a/packages/util/ng-package.json b/packages/util/ng-package.json index 8b729c143..05bc94972 100644 --- a/packages/util/ng-package.json +++ b/packages/util/ng-package.json @@ -7,7 +7,7 @@ "entryFile": "public_api.ts", "umdModuleIds": { "date-fns": "DateFns", - "ng-zorro-antd": "ngZorro.antd", + "ng-zorro-antd": "ng-zorro-antd", "extend": "Extend" } } diff --git a/scripts/ci/build-lib.sh b/scripts/ci/build-lib.sh index addf3ca58..5b7b98264 100644 --- a/scripts/ci/build-lib.sh +++ b/scripts/ci/build-lib.sh @@ -5,7 +5,8 @@ set -u -e -o pipefail cd $(dirname $0)/../.. -PACKAGES=(acl +PACKAGES=(testing + acl util theme abc