mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Created DateRangeRow test
This commit is contained in:
parent
5eb4a3adec
commit
cff96eeccc
1 changed files with 40 additions and 0 deletions
40
test/utils/DateRangeRow.test.js
Normal file
40
test/utils/DateRangeRow.test.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import DateRangeRow from '../../src/utils/DateRangeRow';
|
||||||
|
import DateInput from '../../src/utils/DateInput';
|
||||||
|
|
||||||
|
describe('<DateRangeRow />', () => {
|
||||||
|
let wrapper;
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue