mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 21:46:20 +00:00
Added tests for new visits settings
This commit is contained in:
26
test/utils/dates/DateIntervalSelector.test.tsx
Normal file
26
test/utils/dates/DateIntervalSelector.test.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
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(() => {
|
||||
wrapper = shallow(<DateIntervalSelector active={activeInterval} onChange={onChange} />);
|
||||
});
|
||||
afterEach(() => wrapper?.unmount());
|
||||
|
||||
test('props are passed down to nested DateIntervalDropdownItems', () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user