mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-10 09:33:51 +00:00
Allowed to select 'all' as the default interval for visits
This commit is contained in:
@@ -8,7 +8,7 @@ describe('<DateIntervalDropdownItems />', () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<DateIntervalDropdownItems active="last180days" onChange={onChange} />);
|
||||
wrapper = shallow(<DateIntervalDropdownItems allText="All" active="last180days" onChange={onChange} />);
|
||||
});
|
||||
|
||||
afterEach(jest.clearAllMocks);
|
||||
@@ -16,24 +16,26 @@ describe('<DateIntervalDropdownItems />', () => {
|
||||
|
||||
it('renders expected amount of items', () => {
|
||||
const items = wrapper.find(DropdownItem);
|
||||
const dividerItems = items.findWhere((item) => !!item.prop('divider'));
|
||||
|
||||
expect(items).toHaveLength(DATE_INTERVALS.length);
|
||||
expect(items).toHaveLength(DATE_INTERVALS.length + 2);
|
||||
expect(dividerItems).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('sets expected item as active', () => {
|
||||
const items = wrapper.find(DropdownItem);
|
||||
const EXPECTED_ACTIVE_INDEX = 5;
|
||||
const items = wrapper.find(DropdownItem).findWhere((item) => item.prop('active') !== undefined);
|
||||
const EXPECTED_ACTIVE_INDEX = 6;
|
||||
|
||||
expect.assertions(DATE_INTERVALS.length);
|
||||
expect.assertions(DATE_INTERVALS.length + 1);
|
||||
items.forEach((item, index) => expect(item.prop('active')).toEqual(index === EXPECTED_ACTIVE_INDEX));
|
||||
});
|
||||
|
||||
it('triggers onChange callback when selecting an element', () => {
|
||||
const items = wrapper.find(DropdownItem);
|
||||
|
||||
items.at(2).simulate('click');
|
||||
items.at(4).simulate('click');
|
||||
items.at(1).simulate('click');
|
||||
items.at(6).simulate('click');
|
||||
items.at(3).simulate('click');
|
||||
expect(onChange).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user