2021-03-06 19:21:23 +03:00
|
|
|
import { shallow, ShallowWrapper } from 'enzyme';
|
|
|
|
import { DateInterval, rangeOrIntervalToString } from '../../../src/utils/dates/types';
|
|
|
|
import { DateIntervalSelector } from '../../../src/utils/dates/DateIntervalSelector';
|
|
|
|
import { DateIntervalDropdownItems } from '../../../src/utils/dates/DateIntervalDropdownItems';
|
|
|
|
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
|
|
|
|
|
|
|
|
describe('<DateIntervalSelector />', () => {
|
|
|
|
let wrapper: ShallowWrapper;
|
|
|
|
const activeInterval: DateInterval = 'last7Days';
|
|
|
|
const onChange = jest.fn();
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-10-03 22:07:07 +03:00
|
|
|
wrapper = shallow(<DateIntervalSelector allText="All text" active={activeInterval} onChange={onChange} />);
|
2021-03-06 19:21:23 +03:00
|
|
|
});
|
|
|
|
afterEach(() => wrapper?.unmount());
|
|
|
|
|
2021-03-06 19:25:09 +03:00
|
|
|
it('passes props down to nested DateIntervalDropdownItems', () => {
|
2021-03-06 19:21:23 +03:00
|
|
|
const items = wrapper.find(DateIntervalDropdownItems);
|
|
|
|
const dropdown = wrapper.find(DropdownBtn);
|
|
|
|
|
|
|
|
expect(dropdown.prop('text')).toEqual(rangeOrIntervalToString(activeInterval));
|
|
|
|
expect(items).toHaveLength(1);
|
|
|
|
expect(items.prop('onChange')).toEqual(onChange);
|
|
|
|
expect(items.prop('active')).toEqual(activeInterval);
|
2021-10-03 22:07:07 +03:00
|
|
|
expect(items.prop('allText')).toEqual('All text');
|
2021-03-06 19:21:23 +03:00
|
|
|
});
|
|
|
|
});
|