| | |
| | | }); |
| | | |
| | | it('persistent valid months going monthView->yearView->monthView', () => { |
| | | const dateBefore = new Date().getFullYear() + '-06-01', |
| | | component = utils.createDatetime({ viewMode: 'months', isValidDate: (current) => |
| | | const dateBefore = '2018-06-01'; |
| | | const component = utils.createDatetime({ viewMode: 'months', isValidDate: (current) => |
| | | current.isBefore(moment(dateBefore, 'YYYY-MM-DD')) |
| | | }); |
| | | |
| | |
| | | expect(utils.isYearView(component)).toBeTruthy(); |
| | | |
| | | expect(utils.getNthYear(component, 0).hasClass('rdtDisabled')).toEqual(false); |
| | | expect(utils.getNthYear(component, 9).hasClass('rdtDisabled')).toEqual(true); |
| | | expect(utils.getNthYear(component, 10).hasClass('rdtDisabled')).toEqual(true); |
| | | |
| | | utils.clickNthYear(component, 8); |
| | | utils.clickNthYear(component, 9); |
| | | expect(utils.getNthMonth(component, 4).hasClass('rdtDisabled')).toEqual(false); |
| | | expect(utils.getNthMonth(component, 5).hasClass('rdtDisabled')).toEqual(true); |
| | | }); |
| | |
| | | expect(utils.isMonthView(component)).toBeTruthy(); |
| | | utils.clickOnElement(component.find('.rdtSwitch')); |
| | | expect(utils.isYearView(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('toggles calendar when open prop changes', () => { |
| | | const component = utils.createDatetime({ open: false }); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | // expect(component.find('.rdtOpen').length).toEqual(0); |
| | | component.setProps({ open: true }); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | // expect(component.find('.rdtOpen').length).toEqual(1); |
| | | component.setProps({ open: false }); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | // expect(component.find('.rdtOpen').length).toEqual(0); |
| | | }); |
| | | |
| | | it('selectYear', () => { |
| | |
| | | expect(utils.isTimeView(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | xit('className -> type string', () => { |
| | | const component = utils.createDatetime({ className: 'custom-class' }); |
| | | it('className -> type string', () => { |
| | | const component = utils.createDatetimeShallow({ className: 'custom-class' }); |
| | | expect(component.find('.custom-class').length).toEqual(1); |
| | | }); |
| | | |
| | |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | component.find('.form-control').simulate('keyDown', { key: 'Tab', keyCode: 9, which: 9 }); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('disableOnClickOutside=true', () => { |
| | | const date = new Date(2000, 0, 15, 2, 2, 2, 2), |
| | | component = utils.createDatetime({ value: date, disableOnClickOutside: true }); |
| | | |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | utils.openDatepicker(component); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | document.dispatchEvent(new Event('mousedown')); |
| | | component.update(); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('disableOnClickOutside=false', () => { |
| | | const date = new Date(2000, 0, 15, 2, 2, 2, 2), |
| | | component = utils.createDatetime({ value: date, disableOnClickOutside: false }); |
| | | |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | utils.openDatepicker(component); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | document.dispatchEvent(new Event('mousedown')); |
| | | component.update(); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | }); |
| | | |
| | | it('increase time', () => { |
| | |
| | | expect(onChangeFn.mock.calls[0][0].toJSON()).toEqual('2000-03-15T02:02:02.002Z'); |
| | | }); |
| | | |
| | | // Passes locally but not on Travis |
| | | xit('when selecting year', () => { |
| | | const date = Date.UTC(2000, 0, 15, 2, 2, 2, 2), |
| | | onChangeFn = jest.fn(), |