| | |
| | | }); |
| | | |
| | | 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', () => { |
| | |
| | | const component = utils.createDatetime(); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | utils.openDatepicker(component); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('opens picker when clicking on input', () => { |
| | | const component = utils.createDatetime(); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | component.find('.form-control').simulate('click'); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | |
| | | 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(component.find('input.custom-class').length).toEqual(1); |
| | | expect(component.find('input').getDOMNode().type).toEqual('email'); |
| | | expect(component.find('input').getDOMNode().placeholder).toEqual('custom-placeholder'); |
| | | }); |
| | | |
| | | it('renderInput', () => { |
| | | const renderInput = (props, openCalendar) => { |
| | | return ( |
| | | <div> |
| | | <input {...props} /> |
| | | <button className="custom-open" onClick={openCalendar}>open calendar</button> |
| | | </div> |
| | | ); |
| | | }; |
| | | const component = utils.createDatetime({ renderInput }); |
| | | |
| | | expect(component.find('button.custom-open').length).toEqual(1); |
| | | expect(utils.isOpen(component)).toBeFalsy(); |
| | | utils.clickOnElement(component.find('button.custom-open')); |
| | | expect(utils.isOpen(component)).toBeTruthy(); |
| | | }); |
| | | |
| | | it('renderDay', () => { |
| | |
| | | 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(), |