2018-08-12 10:01:11 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2019-01-06 01:16:13 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
2018-08-12 11:18:26 +03:00
|
|
|
import moment from 'moment';
|
2018-11-01 11:05:20 +03:00
|
|
|
import DateInput from '../../src/utils/DateInput';
|
2018-08-12 10:01:11 +03:00
|
|
|
|
|
|
|
describe('<DateInput />', () => {
|
|
|
|
let wrapped;
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
|
|
|
wrapped = shallow(<DateInput {...props} />);
|
2018-08-26 00:39:27 +03:00
|
|
|
|
2018-08-12 10:01:11 +03:00
|
|
|
return wrapped;
|
|
|
|
};
|
2018-08-26 00:39:27 +03:00
|
|
|
|
2018-11-01 11:16:18 +03:00
|
|
|
afterEach(() => wrapped && wrapped.unmount());
|
2018-08-12 10:01:11 +03:00
|
|
|
|
|
|
|
it('wrapps a DatePicker', () => {
|
|
|
|
wrapped = createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows calendar icon when input is not clearable', () => {
|
|
|
|
wrapped = createComponent({ isClearable: false });
|
|
|
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows calendar icon when input is clearable but selected value is nil', () => {
|
|
|
|
wrapped = createComponent({ isClearable: true, selected: null });
|
|
|
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show calendar icon when input is clearable', () => {
|
2018-08-12 11:18:26 +03:00
|
|
|
wrapped = createComponent({ isClearable: true, selected: moment() });
|
2018-08-12 10:01:11 +03:00
|
|
|
expect(wrapped.find(FontAwesomeIcon)).toHaveLength(0);
|
|
|
|
});
|
|
|
|
});
|