Skip to content

Commit

Permalink
fix(module: calendar): fix timepicker select error (#216)
Browse files Browse the repository at this point in the history
* fix(module: calendar): fix timepicker select error
  • Loading branch information
nuonuoge authored and 3fuyu committed Jan 4, 2019
1 parent ec88d97 commit 03ffa9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions components/calendar/calendar.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ModalModule } from '../modal/modal.module';
import { Modal } from '../modal/modal.service';
import { ModalComponent } from '../modal/modal.component';
import { CalendarModule } from './calendar.module';
import { dispatchTouchEvent } from '../core/testing';

describe('CalendarComponent', () => {
let component: TestCalendarBasicComponent;
Expand Down Expand Up @@ -169,6 +170,7 @@ describe('CalendarComponent', () => {

it('should show picker', () => {
component.state.show = true;
component.state.type = 'one';
component.state.pickTime = true;
component.state.now = new Date(2018, 8, 2);
component.state.mimDate = new Date(2018, 8, 2);
Expand All @@ -178,15 +180,26 @@ describe('CalendarComponent', () => {
.querySelectorAll('.date .row')[1]
.querySelector('.cell')
.click();
calendarEle.nativeElement
.querySelectorAll('.date .row')[2]
.querySelector('.cell')
.click();
fixture.detectChanges();
expect(calendarEle.nativeElement.querySelector('calendartimepicker').classList).toContain(
'time-picker',
'timepicker is right'
);
const touchEl = calendarEle.nativeElement
.querySelector('calendartimepicker')
.querySelector('.am-picker-col-mask');
dispatchTouchEvent(touchEl, 'touchstart', 0, 0);
fixture.detectChanges();
dispatchTouchEvent(touchEl, 'touchmove', 0, 30);
fixture.detectChanges();
dispatchTouchEvent(touchEl, 'touchend', 0, 60);
fixture.detectChanges();
calendarEle.nativeElement
.querySelector('calendarconfirmpanel')
.querySelector('.button')
.click();
fixture.detectChanges();
expect(component.state.startDate.toLocaleString()).toContain('12:00:00');
});

it('should change type', () => {
Expand Down
4 changes: 2 additions & 2 deletions components/calendar/timepicker/timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export class TimePickerComponent {

constructor() {}

onDateChange = (date: Date) => {
onDateChange = (date: {date: Date, index: number}) => {
const { onValueChange } = this.props;
onValueChange && onValueChange(date);
onValueChange && onValueChange(date.date);
}

getMinTime(date?: Date) {
Expand Down

0 comments on commit 03ffa9e

Please sign in to comment.