mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 14:21:49 +00:00
Fixed tests after bootstrap 5 update
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { Input } from 'reactstrap';
|
||||
import { FormText } from '../../src/utils/forms/FormText';
|
||||
import {
|
||||
RealTimeUpdatesSettings as RealTimeUpdatesSettingsOptions,
|
||||
Settings,
|
||||
} from '../../src/settings/reducers/settings';
|
||||
import RealTimeUpdatesSettings from '../../src/settings/RealTimeUpdatesSettings';
|
||||
import ToggleSwitch from '../../src/utils/ToggleSwitch';
|
||||
import { LabeledFormGroup } from '../../src/utils/forms/LabeledFormGroup';
|
||||
|
||||
describe('<RealTimeUpdatesSettings />', () => {
|
||||
const toggleRealTimeUpdates = jest.fn();
|
||||
@@ -32,31 +34,31 @@ describe('<RealTimeUpdatesSettings />', () => {
|
||||
it('renders enabled real time updates as expected', () => {
|
||||
const wrapper = createWrapper({ enabled: true });
|
||||
const toggle = wrapper.find(ToggleSwitch);
|
||||
const label = wrapper.find('label');
|
||||
const label = wrapper.find(LabeledFormGroup);
|
||||
const input = wrapper.find(Input);
|
||||
const small = wrapper.find('small');
|
||||
const formText = wrapper.find(FormText);
|
||||
|
||||
expect(toggle.prop('checked')).toEqual(true);
|
||||
expect(toggle.html()).toContain('processed');
|
||||
expect(toggle.html()).not.toContain('ignored');
|
||||
expect(label.prop('className')).toEqual('');
|
||||
expect(label.prop('labelClassName')).not.toContain('text-muted');
|
||||
expect(input.prop('disabled')).toEqual(false);
|
||||
expect(small).toHaveLength(2);
|
||||
expect(formText).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('renders disabled real time updates as expected', () => {
|
||||
const wrapper = createWrapper({ enabled: false });
|
||||
const toggle = wrapper.find(ToggleSwitch);
|
||||
const label = wrapper.find('label');
|
||||
const label = wrapper.find(LabeledFormGroup);
|
||||
const input = wrapper.find(Input);
|
||||
const small = wrapper.find('small');
|
||||
const formText = wrapper.find(FormText);
|
||||
|
||||
expect(toggle.prop('checked')).toEqual(false);
|
||||
expect(toggle.html()).not.toContain('processed');
|
||||
expect(toggle.html()).toContain('ignored');
|
||||
expect(label.prop('className')).toEqual('text-muted');
|
||||
expect(label.prop('labelClassName')).toContain('text-muted');
|
||||
expect(input.prop('disabled')).toEqual(true);
|
||||
expect(small).toHaveLength(1);
|
||||
expect(formText).toHaveLength(1);
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -79,11 +81,11 @@ describe('<RealTimeUpdatesSettings />', () => {
|
||||
it.each([[ undefined ], [ 0 ]])('shows expected children when interval is 0 or undefined', (interval) => {
|
||||
const wrapper = createWrapper({ enabled: true, interval });
|
||||
const span = wrapper.find('span');
|
||||
const small = wrapper.find('small').at(1);
|
||||
const formText = wrapper.find(FormText).at(1);
|
||||
const input = wrapper.find(Input);
|
||||
|
||||
expect(span).toHaveLength(0);
|
||||
expect(small.html()).toContain('Updates will be reflected in the UI as soon as they happen.');
|
||||
expect(formText.html()).toContain('Updates will be reflected in the UI as soon as they happen.');
|
||||
expect(input.prop('value')).toEqual('');
|
||||
});
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ describe('<ShortUrlCreationSettings />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ validateUrls: true }, 'Validate URL checkbox will be checked' ],
|
||||
[{ validateUrls: false }, 'Validate URL checkbox will be unchecked' ],
|
||||
[ undefined, 'Validate URL checkbox will be unchecked' ],
|
||||
[{ validateUrls: true }, '<b>Validate URL</b> checkbox will be <b>checked</b>' ],
|
||||
[{ validateUrls: false }, '<b>Validate URL</b> checkbox will be <b>unchecked</b>' ],
|
||||
[ undefined, '<b>Validate URL</b> checkbox will be <b>unchecked</b>' ],
|
||||
])('shows expected helper text for URL validation', (shortUrlCreation, expectedText) => {
|
||||
const wrapper = createWrapper(shortUrlCreation);
|
||||
const validateUrlText = wrapper.find(FormText).first();
|
||||
@@ -58,9 +58,9 @@ describe('<ShortUrlCreationSettings />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ forwardQuery: true }, 'Forward query params on redirect checkbox will be checked' ],
|
||||
[{ forwardQuery: false }, 'Forward query params on redirect checkbox will be unchecked' ],
|
||||
[{}, 'Forward query params on redirect checkbox will be checked' ],
|
||||
[{ forwardQuery: true }, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>' ],
|
||||
[{ forwardQuery: false }, '<b>Forward query params on redirect</b> checkbox will be <b>unchecked</b>' ],
|
||||
[{}, '<b>Forward query params on redirect</b> checkbox will be <b>checked</b>' ],
|
||||
])('shows expected helper text for query forwarding', (shortUrlCreation, expectedText) => {
|
||||
const wrapper = createWrapper({ validateUrls: true, ...shortUrlCreation });
|
||||
const forwardQueryText = wrapper.find(FormText).at(1);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { FormGroup } from 'reactstrap';
|
||||
import { Settings, TagsMode, TagsSettings as TagsSettingsOptions } from '../../src/settings/reducers/settings';
|
||||
import { TagsModeDropdown } from '../../src/tags/TagsModeDropdown';
|
||||
import { TagsSettings } from '../../src/settings/TagsSettings';
|
||||
import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
|
||||
import { TagsOrder } from '../../src/tags/data/TagsListChildrenProps';
|
||||
import { LabeledFormGroup } from '../../src/utils/forms/LabeledFormGroup';
|
||||
import { FormText } from '../../src/utils/forms/FormText';
|
||||
|
||||
describe('<TagsSettings />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
@@ -21,7 +22,7 @@ describe('<TagsSettings />', () => {
|
||||
|
||||
it('renders expected amount of groups', () => {
|
||||
const wrapper = createWrapper();
|
||||
const groups = wrapper.find(FormGroup);
|
||||
const groups = wrapper.find(LabeledFormGroup);
|
||||
|
||||
expect(groups).toHaveLength(2);
|
||||
});
|
||||
@@ -34,10 +35,10 @@ describe('<TagsSettings />', () => {
|
||||
])('shows expected tags displaying mode', (tags, expectedMode) => {
|
||||
const wrapper = createWrapper(tags);
|
||||
const dropdown = wrapper.find(TagsModeDropdown);
|
||||
const small = wrapper.find('small');
|
||||
const formText = wrapper.find(FormText);
|
||||
|
||||
expect(dropdown.prop('mode')).toEqual(expectedMode);
|
||||
expect(small.html()).toContain(`Tags will be displayed as <b>${expectedMode}</b>.`);
|
||||
expect(formText.html()).toContain(`Tags will be displayed as <b>${expectedMode}</b>.`);
|
||||
});
|
||||
|
||||
it.each([
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Settings } from '../../src/settings/reducers/settings';
|
||||
import { VisitsSettings } from '../../src/settings/VisitsSettings';
|
||||
import { SimpleCard } from '../../src/utils/SimpleCard';
|
||||
import { DateIntervalSelector } from '../../src/utils/dates/DateIntervalSelector';
|
||||
import { LabeledFormGroup } from '../../src/utils/forms/LabeledFormGroup';
|
||||
|
||||
describe('<VisitsSettings />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
@@ -21,7 +22,7 @@ describe('<VisitsSettings />', () => {
|
||||
const wrapper = createWrapper();
|
||||
|
||||
expect(wrapper.find(SimpleCard).prop('title')).toEqual('Visits');
|
||||
expect(wrapper.find('label').prop('children')).toEqual('Default interval to load on visits sections:');
|
||||
expect(wrapper.find(LabeledFormGroup).prop('label')).toEqual('Default interval to load on visits sections:');
|
||||
expect(wrapper.find(DateIntervalSelector)).toHaveLength(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user