Skip to content

Commit

Permalink
test(module:time-picker): update testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Depickere Sven committed Dec 15, 2020
1 parent 682b566 commit 0d50558
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions components/time-picker/time-picker.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { OverlayContainer } from '@angular/cdk/overlay';
import { Component, DebugElement, NO_ERRORS_SCHEMA, OnInit, ViewChild } from '@angular/core';
import { Component, DebugElement, NO_ERRORS_SCHEMA, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, inject, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { dispatchMouseEvent } from 'ng-zorro-antd/core/testing';
import { getPickerInput } from 'ng-zorro-antd/date-picker/testing/util';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { en_GB, NzI18nInterface, NzI18nModule, NzI18nService } from '../i18n';
import { en_GB, NzI18nModule, NzI18nService } from '../i18n';
import { NzTimePickerComponent } from './time-picker.component';
import { NzTimePickerModule } from './time-picker.module';

Expand Down Expand Up @@ -162,14 +160,15 @@ describe('time-picker', () => {

it('should detect the language changes', fakeAsync(() => {
let placeHolderValue: string | undefined;
testComponent.i18nPlaceHolder$.subscribe(v => (placeHolderValue = v));
placeHolderValue = timeElement.nativeElement.querySelector('input').placeholder;

expect(placeHolderValue).toBe('请选择时间');

srv.setLocale(en_GB);
tick(400);
fixture.detectChanges();

placeHolderValue = timeElement.nativeElement.querySelector('input').placeholder;
expect(placeHolderValue).toBe('Select time');
}));
});
Expand All @@ -188,28 +187,20 @@ describe('time-picker', () => {
(ngModelChange)="onChange($event)"
[(nzOpen)]="open"
(nzOpenChange)="openChange($event)"
[nzPlaceHolder]="i18nPlaceHolder$ | async"
[nzDisabled]="disabled"
[nzUse12Hours]="use12Hours"
[nzSuffixIcon]="nzSuffixIcon"
></nz-time-picker>
`
})
export class NzTestTimePickerComponent implements OnInit {
export class NzTestTimePickerComponent {
open = false;
openChange = jasmine.createSpy('open change');
autoFocus = false;
date: Date | string = new Date();
disabled = false;
use12Hours = false;
nzSuffixIcon?: string;
i18nPlaceHolder$: Observable<string | undefined> = of(undefined);
onChange(): void {}
@ViewChild(NzTimePickerComponent, { static: false }) nzTimePickerComponent!: NzTimePickerComponent;

constructor(private i18n: NzI18nService) {}

ngOnInit(): void {
this.i18nPlaceHolder$ = this.i18n.localeChange.pipe(map((nzLocale: NzI18nInterface) => nzLocale.TimePicker.placeholder));
}
}

0 comments on commit 0d50558

Please sign in to comment.