2020-08-31 19:38:27 +03:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
2022-05-28 12:16:59 +03:00
|
|
|
import { DateRangeRow } from '../../../src/utils/dates/DateRangeRow';
|
|
|
|
import { DateInput } from '../../../src/utils/DateInput';
|
2020-01-14 22:20:27 +03:00
|
|
|
|
|
|
|
describe('<DateRangeRow />', () => {
|
2020-08-31 19:38:27 +03:00
|
|
|
let wrapper: ShallowWrapper;
|
2020-01-14 22:20:27 +03:00
|
|
|
const onEndDateChange = jest.fn();
|
|
|
|
const onStartDateChange = jest.fn();
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = shallow(<DateRangeRow onEndDateChange={onEndDateChange} onStartDateChange={onStartDateChange} />);
|
|
|
|
});
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.unmount();
|
|
|
|
jest.clearAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders two date inputs', () => {
|
|
|
|
const dateInput = wrapper.find(DateInput);
|
|
|
|
|
|
|
|
expect(dateInput).toHaveLength(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('invokes start date callback when change event is triggered on first input', () => {
|
|
|
|
const dateInput = wrapper.find(DateInput).first();
|
|
|
|
|
|
|
|
expect(onStartDateChange).not.toHaveBeenCalled();
|
|
|
|
dateInput.simulate('change');
|
|
|
|
expect(onStartDateChange).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('invokes end date callback when change event is triggered on second input', () => {
|
|
|
|
const dateInput = wrapper.find(DateInput).last();
|
|
|
|
|
|
|
|
expect(onEndDateChange).not.toHaveBeenCalled();
|
|
|
|
dateInput.simulate('change');
|
|
|
|
expect(onEndDateChange).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|