Skip to content

Commit

Permalink
fix: specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Mar 12, 2019
1 parent 0f3052b commit 0ba32ba
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion components/steps/nz-steps.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DebugElement, TemplateRef, ViewChild } from '@angular/core';
import { async, fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

Expand Down
2 changes: 1 addition & 1 deletion components/table/nz-th.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, DebugElement, ViewChild } from '@angular/core';
import { fakeAsync, flush, ComponentFixture, TestBed } from '@angular/core/testing';
import { fakeAsync, flush, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { NzIconTestModule } from '../icon/nz-icon-test.module';
Expand Down
10 changes: 5 additions & 5 deletions components/tree/nz-tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ describe('nz-tree', () => {

it('test set nzTreeNode', fakeAsync(() => {
// get 0-0 node
const node = fixture.componentInstance.treeComponent.getTreeNodeByKey('0-0');
const node = fixture.componentInstance.treeComponent.getTreeNodeByKey('0-0')!;
node.title = '0-0-reset';
fixture.detectChanges();
expect(treeElement.querySelectorAll('[title=\'0-0-reset\']').length).toEqual(1);
Expand Down Expand Up @@ -437,7 +437,7 @@ describe('nz-tree', () => {
fixture.detectChanges();
// drop 0-0-0 to 0-0 pre
let targetNode = treeNodes[ 0 ]; // 0-0
treeService = treeNodes[ 1 ].treeService;
treeService = treeNodes[ 1 ].treeService!;
treeService.dropAndApply(targetNode, -1);
expect(treeNodes[ 0 ].title).toEqual('0-0-0');
expect(treeNodes[ 0 ].level).toEqual(0);
Expand Down Expand Up @@ -563,16 +563,16 @@ describe('nz-tree', () => {
fixture.componentInstance.selectedKeys = [ ...fixture.componentInstance.selectedKeys ];
fixture.detectChanges();
// get node by key
let node = fixture.componentInstance.treeComponent.getTreeNodeByKey('10001');
let node = fixture.componentInstance.treeComponent.getTreeNodeByKey('10001')!;
expect(node.title).toEqual('child1');
// test clear children
node.clearChildren();
expect(node.getChildren().length).toEqual(0);
// remove self
node.remove();
expect(node.getParentNode().getChildren().findIndex(v => v.key === node.key)).toEqual(-1);
expect(node.getParentNode()!.getChildren().findIndex(v => v.key === node.key)).toEqual(-1);
// test selectable false and click it
node = fixture.componentInstance.treeComponent.getTreeNodeByKey('1001');
node = fixture.componentInstance.treeComponent.getTreeNodeByKey('1001')!;
node.isSelectable = false;
fixture.detectChanges();
// add nzTreeNode children to clear loading state, root click will not change
Expand Down
46 changes: 30 additions & 16 deletions components/upload/upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,35 @@ import { NzUploadBtnComponent } from './nz-upload-btn.component';
import { NzUploadListComponent } from './nz-upload-list.component';
import { NzUploadComponent } from './nz-upload.component';

const FILECONTENT = [`iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==`];
const FILECONTENT = [ `iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==` ];
const FILE = new File(FILECONTENT, '');
const PNGSMALL = { target: { files: [new File(FILECONTENT, 'test.png', {
type: 'image/png'
})] } };
const JPGSMALL = { target: { files: [new File(FILECONTENT, 'test.jpg', {
type: 'image/jpg'
})] } };
const PNGSMALL = {
target: {
files: [ new File(FILECONTENT, 'test.png', {
type: 'image/png'
}) ]
}
};
const JPGSMALL = {
target: {
files: [ new File(FILECONTENT, 'test.jpg', {
type: 'image/jpg'
}) ]
}
};
const LARGEFILE = {
name: 'test.png',
size: 500001,
type: 'image/png'
};
const PNGBIG = { target: { files: { 0: LARGEFILE, length: 1, item: () => LARGEFILE } } };

class Item {
children?: Item[];

constructor(public name: string) {}
}

describe('upload', () => {

it('should be throw error when not import HttpClient module', () => {
Expand Down Expand Up @@ -1254,7 +1268,7 @@ class TestUploadComponent {
this._beforeUpload = true;
this._beforeUploadList = fileList;
return true;
}
};
nzCustomRequest: any;
nzData: any;
nzFilter: UploadFilter[] = [];
Expand All @@ -1270,12 +1284,12 @@ class TestUploadComponent {
_onPreview = false;
onPreview = (): void => {
this._onPreview = true;
}
};
_onRemove = false;
onRemove: null | ((file: UploadFile) => boolean | Observable<boolean>) = (): boolean => {
this._onRemove = true;
return true;
}
};
_nzChange: UploadChangeParam;

nzChange(value: UploadChangeParam): void { this._nzChange = value; }
Expand Down Expand Up @@ -1329,11 +1343,11 @@ class TestUploadListComponent {
_onPreview = false;
onPreview: VoidFunction | null = (): void => {
this._onPreview = true;
}
};
_onRemove = false;
onRemove: any = (): void => {
this._onRemove = true;
}
};
}

@Component({
Expand All @@ -1346,9 +1360,9 @@ class TestUploadBtnComponent {
options: ZipButtonOptions = {
disabled : false,
openFileDialogOnClick: true,
filters: [],
customRequest: undefined,
onStart: () => {},
onError: () => {}
filters : [],
customRequest : undefined,
onStart : () => {},
onError : () => {}
};
}

0 comments on commit 0ba32ba

Please sign in to comment.