Fixed tests and typos

This commit is contained in:
Alejandro Celaya
2020-01-14 20:12:30 +01:00
parent b60908a5e9
commit 5eb4a3adec
5 changed files with 29 additions and 11 deletions

View File

@@ -1,8 +1,10 @@
import React from 'react';
import { shallow } from 'enzyme';
import each from 'jest-each';
import searchBarCreator from '../../src/short-urls/SearchBar';
import SearchField from '../../src/utils/SearchField';
import Tag from '../../src/tags/helpers/Tag';
import DateRangeRow from '../../src/utils/DateRangeRow';
describe('<SearchBar />', () => {
let wrapper;
@@ -20,6 +22,12 @@ describe('<SearchBar />', () => {
expect(wrapper.find(SearchField)).toHaveLength(1);
});
it('renders a DateRangeRow', () => {
wrapper = shallow(<SearchBar shortUrlsListParams={{}} />);
expect(wrapper.find(DateRangeRow)).toHaveLength(1);
});
it('renders no tags when the list of tags is empty', () => {
wrapper = shallow(<SearchBar shortUrlsListParams={{}} />);
@@ -53,4 +61,13 @@ describe('<SearchBar />', () => {
tag.simulate('close');
expect(listShortUrlsMock).toHaveBeenCalledTimes(1);
});
each([ 'startDateChange', 'endDateChange' ]).it('updates short URLs list when date range changes', (event) => {
wrapper = shallow(<SearchBar shortUrlsListParams={{}} listShortUrls={listShortUrlsMock} />);
const dateRange = wrapper.find(DateRangeRow);
expect(listShortUrlsMock).not.toHaveBeenCalled();
dateRange.simulate(event);
expect(listShortUrlsMock).toHaveBeenCalledTimes(1);
});
});