Permalink
Browse files

fix(module: date-picker): fix year-picker and month-picker style erro…

…r within compacted input group (#2136)

GLTM
  • Loading branch information...
hungtcs authored and vthinkxie committed Sep 19, 2018
1 parent 320d582 commit 049212f3b1fb3c64358ba870c362cfe5712c5a30
@@ -9,6 +9,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import isBefore from 'date-fns/is_before';
import { dispatchMouseEvent } from '../core/testing';
import { NzInputModule } from '../input/nz-input.module';
import { NzDatePickerModule } from './date-picker.module';
import { CandyDate } from './lib/candy-date';
import { PickerResultSingle } from './standard-types';
@@ -24,7 +25,7 @@ describe('NzMonthPickerComponent', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports : [ FormsModule, NoopAnimationsModule, NzDatePickerModule ],
imports : [FormsModule, NoopAnimationsModule, NzDatePickerModule, NzInputModule ],
providers : [],
declarations: [
NzTestMonthPickerComponent
@@ -146,10 +147,21 @@ describe('NzMonthPickerComponent', () => {
it('should support nzClassName', () => {
const className = fixtureInstance.nzClassName = 'my-test-class';
fixture.detectChanges();
const picker = debugElement.query(By.css('.ant-calendar-picker')).nativeElement as HTMLElement;
const picker = debugElement.queryAll(By.css('.ant-calendar-picker'))[1].nativeElement as HTMLElement;
expect(picker.classList.contains(className)).toBeTruthy();
});
it('should support nzCompact', () => {
fixtureInstance.useSuite = 4;
fixture.detectChanges();
const pickerInput = debugElement.query(By.css('input.ant-calendar-picker-input')).nativeElement as HTMLElement;
expect(pickerInput).not.toBeNull();
const compStyles = window.getComputedStyle(pickerInput);
expect(compStyles.getPropertyValue('border-top-right-radius') === '0px').toBeTruthy();
expect(compStyles.getPropertyValue('border-bottom-right-radius') === '0px').toBeTruthy();
});
it('should support nzDisabledDate', fakeAsync(() => {
fixture.detectChanges();
const compareDate = new Date('2018-11-15 00:00:00');
@@ -441,11 +453,17 @@ describe('NzMonthPickerComponent', () => {
<!-- Suite 3 -->
<nz-month-picker *ngSwitchCase="3" nzOpen [(ngModel)]="modelValue"></nz-month-picker>
<!-- Suite 4 -->
<nz-input-group *ngSwitchCase="4" nzCompact>
<nz-month-picker style="width: 200px;"></nz-month-picker>
<input nz-input type="text" style="width: 200px;" />
</nz-input-group>
</ng-container>
`
})
class NzTestMonthPickerComponent {
useSuite: 1 | 2 | 3;
useSuite: 1 | 2 | 3 | 4;
@ViewChild('tplExtraFooter') tplExtraFooter: TemplateRef<void>;
// --- Suite 1
@@ -12,7 +12,8 @@ import { HeaderPickerComponent, SupportHeaderPanel } from './header-picker.compo
useExisting: forwardRef(() => NzMonthPickerComponent)
}],
host : {
'[class.ant-checkbox-group]': 'true'
'[class.ant-checkbox-group]': 'true',
'[class.ant-calendar-picker]': 'true'
}
})
@@ -9,6 +9,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import * as isBefore from 'date-fns/is_before';
import { dispatchMouseEvent } from '../core/testing';
import { NzInputModule } from '../input/nz-input.module';
import { NzDatePickerModule } from './date-picker.module';
import { CandyDate } from './lib/candy-date';
import { PickerResultSingle } from './standard-types';
@@ -24,7 +25,7 @@ describe('NzYearPickerComponent', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports : [ FormsModule, NoopAnimationsModule, NzDatePickerModule ],
imports : [ FormsModule, NoopAnimationsModule, NzDatePickerModule, NzInputModule ],
providers : [],
declarations: [
NzTestYearPickerComponent
@@ -146,10 +147,21 @@ describe('NzYearPickerComponent', () => {
it('should support nzClassName', () => {
const className = fixtureInstance.nzClassName = 'my-test-class';
fixture.detectChanges();
const picker = debugElement.query(By.css('.ant-calendar-picker')).nativeElement as HTMLElement;
const picker = debugElement.queryAll(By.css('.ant-calendar-picker'))[1].nativeElement as HTMLElement;
expect(picker.classList.contains(className)).toBeTruthy();
});
it('should support nzCompact', () => {
fixtureInstance.useSuite = 4;
fixture.detectChanges();
const pickerInput = debugElement.query(By.css('input.ant-calendar-picker-input')).nativeElement as HTMLElement;
expect(pickerInput).not.toBeNull();
const compStyles = window.getComputedStyle(pickerInput);
expect(compStyles.getPropertyValue('border-top-right-radius') === '0px').toBeTruthy();
expect(compStyles.getPropertyValue('border-bottom-right-radius') === '0px').toBeTruthy();
});
it('should support nzLocale', () => {
const featureKey = 'TEST_PLACEHOLDER';
fixtureInstance.nzLocale = { lang: { placeholder: featureKey } };
@@ -386,11 +398,18 @@ describe('NzYearPickerComponent', () => {
<!-- Suite 3 -->
<nz-year-picker *ngSwitchCase="3" nzOpen [(ngModel)]="modelValue"></nz-year-picker>
<!-- Suite 4 -->
<nz-input-group *ngSwitchCase="4" nzCompact>
<nz-year-picker style="width: 200px;"></nz-year-picker>
<input nz-input type="text" style="width: 200px;" />
</nz-input-group>
</ng-container>
`
})
class NzTestYearPickerComponent {
useSuite: 1 | 2 | 3;
useSuite: 1 | 2 | 3 | 4;
@ViewChild('tplExtraFooter') tplExtraFooter: TemplateRef<void>;
// --- Suite 1
@@ -12,7 +12,8 @@ import { HeaderPickerComponent, SupportHeaderPanel } from './header-picker.compo
useExisting: forwardRef(() => NzYearPickerComponent)
}],
host : {
'[class.ant-checkbox-group]': 'true'
'[class.ant-checkbox-group]': 'true',
'[class.ant-calendar-picker]': 'true'
}
})

0 comments on commit 049212f

Please sign in to comment.