Ensured filter for bots does not show for Shlink older than 2.7.0

This commit is contained in:
Alejandro Celaya
2021-06-22 21:01:20 +02:00
parent 638ce89780
commit affe2309b0
5 changed files with 39 additions and 10 deletions

View File

@@ -14,7 +14,7 @@ describe('<EditShortUrl />', () => {
const ShortUrlForm = () => null;
const goBack = jest.fn();
const getShortUrlDetail = jest.fn();
const editShortUrl = jest.fn();
const editShortUrl = jest.fn(async () => Promise.resolve());
const shortUrlCreation = { validateUrls: true };
const createWrapper = (detail: Partial<ShortUrlDetail> = {}, edition: Partial<ShortUrlEdition> = {}) => {
const EditSHortUrl = createEditShortUrl(ShortUrlForm);

View File

@@ -12,7 +12,7 @@ import { SimpleCard } from '../../src/utils/SimpleCard';
describe('<ShortUrlForm />', () => {
let wrapper: ShallowWrapper;
const TagsSelector = () => null;
const createShortUrl = jest.fn();
const createShortUrl = jest.fn(async () => Promise.resolve());
const createWrapper = (selectedServer: SelectedServer = null, mode: Mode = 'create') => {
const ShortUrlForm = createShortUrlForm(TagsSelector, () => null);

View File

@@ -8,7 +8,12 @@ describe('<VisitsFilterDropdown />', () => {
const onChange = jest.fn();
const createWrapper = (selected: VisitsFilter = {}, isOrphanVisits = true) => {
wrapper = shallow(
<VisitsFilterDropdown isOrphanVisits={isOrphanVisits} selected={selected} onChange={onChange} />,
<VisitsFilterDropdown
isOrphanVisits={isOrphanVisits}
botsSupported={true}
selected={selected}
onChange={onChange}
/>,
);
return wrapper;
@@ -68,4 +73,17 @@ describe('<VisitsFilterDropdown />', () => {
expect(onChange).toHaveBeenCalledWith(expectedSelection);
});
it('does not render the component when neither orphan visits or bots filtering will be displayed', () => {
const wrapper = shallow(
<VisitsFilterDropdown
isOrphanVisits={false}
botsSupported={false}
selected={{}}
onChange={onChange}
/>,
);
expect(wrapper.text()).toEqual('');
});
});