Skip to content

Commit

Permalink
fix: fix test ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Apr 28, 2020
1 parent c6bd419 commit 10d1740
Show file tree
Hide file tree
Showing 68 changed files with 330 additions and 379 deletions.
7 changes: 3 additions & 4 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,8 @@ describe('affix-extra', () => {
`
})
class TestAffixComponent {
@ViewChild(NzAffixComponent, { static: true })
nzAffixComponent: NzAffixComponent;
@ViewChild(NzAffixComponent, { static: true }) nzAffixComponent!: NzAffixComponent;
fakeTarget: string | Element | Window | null = null;
newOffset: {};
newOffsetBottom: {};
newOffset: {} = {};
newOffsetBottom: {} = {};
}
10 changes: 4 additions & 6 deletions components/alert/alert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,19 @@ describe('alert', () => {
`
})
export class NzDemoTestBasicComponent {
@ViewChild('template', { static: false }) template: TemplateRef<void>;
@ViewChild('template', { static: false }) template!: TemplateRef<void>;
banner = false;
closeable = false;
closeText: string | TemplateRef<void>;
closeText?: string | TemplateRef<void>;
description: string | TemplateRef<void> = 'description';
message: string | TemplateRef<void> = 'message';
showIcon = false;
iconType: string;
iconType?: string;
type = 'info';
onClose = jasmine.createSpy('close callback');
}

@Component({
template: `
<nz-alert nzBanner> </nz-alert>
`
template: ` <nz-alert nzBanner> </nz-alert> `
})
export class NzDemoTestBannerComponent {}
2 changes: 1 addition & 1 deletion components/anchor/anchor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ describe('anchor', () => {
styleUrls: ['./style/patch.less']
})
export class TestComponent {
@ViewChild(NzAnchorComponent, { static: false }) comp: NzAnchorComponent;
@ViewChild(NzAnchorComponent, { static: false }) comp!: NzAnchorComponent;
nzAffix = true;
nzBounds = 5;
nzOffsetTop = 0;
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/autocomplete-trigger.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
throw getNzAutocompleteMissingPanelError();
}

if (!this.portal) {
if (!this.portal && this.nzAutocomplete.template) {
this.portal = new TemplatePortal(this.nzAutocomplete.template, this.viewContainerRef);
}

Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class NzAutocompleteComponent implements AfterContentInit, AfterViewInit,

showPanel: boolean = true;
isOpen: boolean = false;
activeItem?: NzAutocompleteOptionComponent;
activeItem!: NzAutocompleteOptionComponent;
dropDownPosition: NzDropDownPosition = 'bottom';

/**
Expand Down
30 changes: 15 additions & 15 deletions components/auto-complete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,14 +917,14 @@ describe('auto-complete', () => {
`
})
class NzTestSimpleAutocompleteComponent {
inputValue: string;
inputValue!: string;
filteredOptions: Array<string | number>;
inputControl = new FormControl();
options: Array<string | number> = ['Burns Bay Road', 'Downing Street', 'Wall Street'];

@ViewChild(NzAutocompleteComponent, { static: false }) panel: NzAutocompleteComponent;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChildren(NzAutocompleteOptionComponent) optionComponents: QueryList<NzAutocompleteOptionComponent>;
@ViewChild(NzAutocompleteComponent, { static: false }) panel!: NzAutocompleteComponent;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;
@ViewChildren(NzAutocompleteOptionComponent) optionComponents!: QueryList<NzAutocompleteOptionComponent>;

constructor() {
this.filteredOptions = this.options;
Expand Down Expand Up @@ -953,13 +953,13 @@ class NzTestSimpleAutocompleteComponent {
`
})
class NzTestAutocompletePropertyComponent {
inputValue: string;
width: number;
inputValue?: string;
width?: number;
overlayClassName = '';
overlayStyle = {};
options = ['Burns Bay Road', 'Downing Street', 'Wall Street'];
@ViewChild(NzAutocompleteComponent, { static: false }) panel: NzAutocompleteComponent;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteComponent, { static: false }) panel!: NzAutocompleteComponent;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;

constructor() {}
}
Expand All @@ -968,7 +968,7 @@ class NzTestAutocompletePropertyComponent {
template: ` <input [nzAutocomplete]="auto" /> `
})
class NzTestAutocompleteWithoutPanelComponent {
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;
}

@Component({
Expand All @@ -982,7 +982,7 @@ class NzTestAutocompleteWithoutPanelComponent {
})
class NzTestAutocompleteWithOnPushDelayComponent implements OnInit {
options: string[] = [];
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;

constructor(private cdr: ChangeDetectorRef) {}

Expand Down Expand Up @@ -1014,7 +1014,7 @@ class NzTestAutocompleteWithOnPushDelayComponent implements OnInit {
`
})
class NzTestAutocompleteGroupComponent {
inputValue: string;
inputValue!: string;
optionGroups = [
{
title: '话题',
Expand Down Expand Up @@ -1054,7 +1054,7 @@ class NzTestAutocompleteGroupComponent {
}
];

@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;
}

@Component({
Expand All @@ -1070,7 +1070,7 @@ class NzTestAutocompleteGroupComponent {
class NzTestAutocompleteWithFormComponent {
form: FormGroup;
options = ['Burns Bay Road', 'Downing Street', 'Wall Street'];
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective, { static: false }) trigger!: NzAutocompleteTriggerDirective;

constructor(private fb: FormBuilder) {
this.form = this.fb.group({ formControl: 'Burns' });
Expand All @@ -1095,7 +1095,7 @@ class NzTestAutocompleteDifferentValueWithFormComponent {
{ label: 'Lucy', value: 'lucy' },
{ label: 'Jack', value: 'jack' }
];
@ViewChild(NzAutocompleteTriggerDirective) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective) trigger!: NzAutocompleteTriggerDirective;

constructor(private fb: FormBuilder) {
this.form = this.fb.group({ formControl: 'lucy' });
Expand All @@ -1118,7 +1118,7 @@ class NzTestAutocompleteWithObjectOptionComponent {
{ label: 'Lucy', value: 'lucy' },
{ label: 'Jack', value: 'jack' }
];
@ViewChild(NzAutocompleteTriggerDirective) trigger: NzAutocompleteTriggerDirective;
@ViewChild(NzAutocompleteTriggerDirective) trigger!: NzAutocompleteTriggerDirective;

// tslint:disable-next-line: no-any
compareFun = (o1: any, o2: any) => {
Expand Down
6 changes: 3 additions & 3 deletions components/avatar/avatar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ describe('avatar', () => {
styleUrls: ['./style/index.less']
})
class TestAvatarComponent {
@ViewChild('comp', { static: false }) comp: NzAvatarComponent;
@ViewChild('comp', { static: false }) comp!: NzAvatarComponent;
nzShape = 'square';
nzSize: string | number = 'large';
nzIcon: string | null = 'user';
nzText: string | null = 'A';
nzSrc: string | null = imageBase64;
nzSrcSet: string;
nzAlt: string;
nzSrcSet?: string;
nzAlt?: string;
}
6 changes: 3 additions & 3 deletions components/back-top/back-top.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('Component:nz-back-top', () => {
})
class TestBackTopComponent {
@ViewChild(NzBackTopComponent, { static: true })
nzBackTopComponent: NzBackTopComponent;
nzBackTopComponent!: NzBackTopComponent;

target: HTMLElement | null = null;

Expand All @@ -224,11 +224,11 @@ class TestBackTopComponent {
})
class TestBackTopTemplateComponent {
@ViewChild(NzBackTopComponent, { static: false })
nzBackTopComponent: NzBackTopComponent;
nzBackTopComponent!: NzBackTopComponent;
}

class MockNzScrollService {
mockTopOffset: number;
mockTopOffset: number = 0;

getScroll(): number {
return this.mockTopOffset;
Expand Down
10 changes: 5 additions & 5 deletions components/badge/badge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ export class NzTestBadgeBasicComponent {
inner = true;
overflow = 20;
showZero = false;
status: string;
style: NgStyleInterface;
text: string;
title: string | null;
offset: [number, number];
status!: string;
style!: NgStyleInterface;
text!: string;
title: string | null = null;
offset?: [number, number];
}
2 changes: 1 addition & 1 deletion components/button/button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class TestButtonBindingComponent {
`
})
export class TestButtonWithIconComponent implements OnInit {
title: string;
title?: string;
ngOnInit(): void {
setTimeout(() => (this.title = 'button'), 5000);
}
Expand Down
4 changes: 2 additions & 2 deletions components/carousel/carousel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { NZ_CAROUSEL_CUSTOM_STRATEGIES } from './typings';
`
})
export class NzTestCarouselBasicComponent {
@ViewChild(NzCarouselComponent, { static: false }) nzCarouselComponent: NzCarouselComponent;
@ViewChild(NzCarouselComponent, { static: false }) nzCarouselComponent!: NzCarouselComponent;
dots = true;
dotPosition = 'bottom';
effect = 'scrollx';
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('carousel', () => {
}));

it('should resize content after window resized', fakeAsync(() => {
const resizeSpy = spyOn(testComponent.nzCarouselComponent.strategy, 'withCarouselContents');
const resizeSpy = spyOn(testComponent.nzCarouselComponent.strategy!, 'withCarouselContents');
window.dispatchEvent(new Event('resize'));
tick(16);
expect(resizeSpy).toHaveBeenCalledTimes(1);
Expand Down
6 changes: 3 additions & 3 deletions components/cascader/cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,8 @@ const options5: any[] = []; // tslint:disable-line:no-any
]
})
export class NzDemoCascaderDefaultComponent {
@ViewChild(NzCascaderComponent, { static: true }) cascader: NzCascaderComponent;
@ViewChild('renderTpl', { static: true }) renderTpl: TemplateRef<any>;
@ViewChild(NzCascaderComponent, { static: true }) cascader!: NzCascaderComponent;
@ViewChild('renderTpl', { static: true }) renderTpl!: TemplateRef<any>;

public nzOptions: any[] | null = options1;
public values: string[] | number[] | null = null;
Expand Down Expand Up @@ -2038,7 +2038,7 @@ export class NzDemoCascaderDefaultComponent {
]
})
export class NzDemoCascaderLoadDataComponent {
@ViewChild(NzCascaderComponent, { static: true }) cascader: NzCascaderComponent;
@ViewChild(NzCascaderComponent, { static: true }) cascader!: NzCascaderComponent;

public nzOptions: any[] | null = null;
public values: string[] | null = null;
Expand Down
6 changes: 2 additions & 4 deletions components/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ describe('checkbox', () => {
`
})
export class NzTestCheckboxSingleComponent {
@ViewChild(NzCheckboxComponent, { static: false }) nzCheckboxComponent: NzCheckboxComponent;
@ViewChild(NzCheckboxComponent, { static: false }) nzCheckboxComponent!: NzCheckboxComponent;
disabled = false;
autoFocus = false;
checked = false;
Expand All @@ -321,9 +321,7 @@ export class NzTestCheckboxSingleComponent {
}

@Component({
template: `
<nz-checkbox-group [nzDisabled]="disabled" [ngModel]="options" (ngModelChange)="modelChange($event)"></nz-checkbox-group>
`
template: ` <nz-checkbox-group [nzDisabled]="disabled" [ngModel]="options" (ngModelChange)="modelChange($event)"></nz-checkbox-group> `
})
export class NzTestCheckboxGroupComponent {
options = [
Expand Down
2 changes: 1 addition & 1 deletion components/collapse/collapse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('collapse', () => {
`
})
export class NzTestCollapseBasicComponent {
@ViewChild('headerTemplate', { static: false }) headerTemplate: TemplateRef<void>;
@ViewChild('headerTemplate', { static: false }) headerTemplate!: TemplateRef<void>;
accordion = false;
bordered = true;
disabled = false;
Expand Down
8 changes: 4 additions & 4 deletions components/core/outlet/string_template_outlet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ describe('string template outlet', () => {
`
})
export class StringTemplateOutletTestComponent {
@ViewChild('stringTpl') stringTpl: TemplateRef<NzSafeAny>;
@ViewChild('emptyTpl') emptyTpl: TemplateRef<NzSafeAny>;
@ViewChild('dataTimeTpl') dataTimeTpl: TemplateRef<NzSafeAny>;
@ViewChild(NzStringTemplateOutletDirective) nzStringTemplateOutletDirective: NzStringTemplateOutletDirective;
@ViewChild('stringTpl') stringTpl!: TemplateRef<NzSafeAny>;
@ViewChild('emptyTpl') emptyTpl!: TemplateRef<NzSafeAny>;
@ViewChild('dataTimeTpl') dataTimeTpl!: TemplateRef<NzSafeAny>;
@ViewChild(NzStringTemplateOutletDirective) nzStringTemplateOutletDirective!: NzStringTemplateOutletDirective;
stringTemplateOutlet: TemplateRef<NzSafeAny> | string | null = null;
context: NzSafeAny = { $implicit: '' };
}
2 changes: 1 addition & 1 deletion components/core/services/scroll.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('NzScrollService', () => {
}

class MockPlatformLocation {
hash: string;
hash!: string;
}

beforeEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions components/core/wave/nz-wave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ class WaveContainerWithButtonComponent {
isDestroyed = false;
borderColor = 'rgb(0,255,0)';
backgroundColor = 'rgb(255,255,255)';
@ViewChild('trigger', { static: false }) trigger: ElementRef<HTMLElement>;
@ViewChild(NzWaveDirective, { static: false }) wave: NzWaveDirective;
@ViewChild('trigger', { static: false }) trigger!: ElementRef<HTMLElement>;
@ViewChild(NzWaveDirective, { static: false }) wave!: NzWaveDirective;
}

@Component({
Expand All @@ -298,6 +298,6 @@ class WaveContainerWithExtraNodeComponent {
isDestroyed = false;
borderColor = 'rgb(0,255,0)';
backgroundColor = 'rgb(255,255,255)';
@ViewChild('trigger', { static: false }) trigger: ElementRef<HTMLElement>;
@ViewChild(NzWaveDirective, { static: false }) wave: NzWaveDirective;
@ViewChild('trigger', { static: false }) trigger!: ElementRef<HTMLElement>;
@ViewChild(NzWaveDirective, { static: false }) wave!: NzWaveDirective;
}
Loading

0 comments on commit 10d1740

Please sign in to comment.