= ({
<>
{title}
- ', () => {
+describe('', () => {
const toggleRealTimeUpdates = jest.fn();
const setRealTimeUpdatesInterval = jest.fn();
let wrapper: ShallowWrapper;
- const createWrapper = (realTimeUpdates: Partial = {}) => {
+ const createWrapper = (realTimeUpdates: Partial = {}) => {
const settings = Mock.of({ realTimeUpdates });
wrapper = shallow(
- ', () => {
+describe('', () => {
let wrapper: ShallowWrapper;
const setShortUrlCreationSettings = jest.fn();
- const createWrapper = (shortUrlCreation?: ShortUrlCreationSettings) => {
+ const createWrapper = (shortUrlCreation?: ShortUrlsSettings) => {
wrapper = shallow(
- ({ shortUrlCreation })}
setShortUrlCreationSettings={setShortUrlCreationSettings}
/>,
@@ -68,9 +68,9 @@ describe('', () => {
});
it.each([
- [ { tagFilteringMode: 'includes' } as ShortUrlCreationSettings, 'Suggest tags including input', 'including' ],
+ [ { tagFilteringMode: 'includes' } as ShortUrlsSettings, 'Suggest tags including input', 'including' ],
[
- { tagFilteringMode: 'startsWith' } as ShortUrlCreationSettings,
+ { tagFilteringMode: 'startsWith' } as ShortUrlsSettings,
'Suggest tags starting with input',
'starting with',
],
diff --git a/test/settings/ShortUrlsList.test.tsx b/test/settings/ShortUrlsListSettings.test.tsx
similarity index 67%
rename from test/settings/ShortUrlsList.test.tsx
rename to test/settings/ShortUrlsListSettings.test.tsx
index 3c1136de..f8ca25e7 100644
--- a/test/settings/ShortUrlsList.test.tsx
+++ b/test/settings/ShortUrlsListSettings.test.tsx
@@ -1,16 +1,20 @@
import { shallow, ShallowWrapper } from 'enzyme';
import { Mock } from 'ts-mockery';
-import { DEFAULT_SHORT_URLS_ORDERING, Settings, ShortUrlsListSettings } from '../../src/settings/reducers/settings';
-import { ShortUrlsList } from '../../src/settings/ShortUrlsList';
-import SortingDropdown from '../../src/utils/SortingDropdown';
+import {
+ DEFAULT_SHORT_URLS_ORDERING,
+ Settings,
+ ShortUrlsListSettings as ShortUrlsSettings,
+} from '../../src/settings/reducers/settings';
+import { ShortUrlsListSettings } from '../../src/settings/ShortUrlsListSettings';
+import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
import { ShortUrlsOrder } from '../../src/short-urls/data';
-describe('', () => {
+describe('', () => {
let wrapper: ShallowWrapper;
const setSettings = jest.fn();
- const createWrapper = (shortUrlsList?: ShortUrlsListSettings) => {
+ const createWrapper = (shortUrlsList?: ShortUrlsSettings) => {
wrapper = shallow(
- ({ shortUrlsList })} setShortUrlsListSettings={setSettings} />,
+ ({ shortUrlsList })} setShortUrlsListSettings={setSettings} />,
);
return wrapper;
@@ -27,7 +31,7 @@ describe('', () => {
[{ defaultOrdering: { field: 'visits', dir: 'ASC' } as ShortUrlsOrder }, { field: 'visits', dir: 'ASC' }],
])('shows expected ordering', (shortUrlsList, expectedOrder) => {
const wrapper = createWrapper(shortUrlsList);
- const dropdown = wrapper.find(SortingDropdown);
+ const dropdown = wrapper.find(OrderingDropdown);
expect(dropdown.prop('order')).toEqual(expectedOrder);
});
@@ -39,7 +43,7 @@ describe('', () => {
[ 'title', 'DESC' ],
])('invokes setSettings when ordering changes', (field, dir) => {
const wrapper = createWrapper();
- const dropdown = wrapper.find(SortingDropdown);
+ const dropdown = wrapper.find(OrderingDropdown);
expect(setSettings).not.toHaveBeenCalled();
dropdown.simulate('change', field, dir);
diff --git a/test/settings/Tags.test.tsx b/test/settings/TagsSettings.test.tsx
similarity index 81%
rename from test/settings/Tags.test.tsx
rename to test/settings/TagsSettings.test.tsx
index 8e5440a4..d6ae737b 100644
--- a/test/settings/Tags.test.tsx
+++ b/test/settings/TagsSettings.test.tsx
@@ -1,17 +1,17 @@
import { shallow, ShallowWrapper } from 'enzyme';
import { Mock } from 'ts-mockery';
import { FormGroup } from 'reactstrap';
-import { Settings, TagsMode, TagsSettings } from '../../src/settings/reducers/settings';
+import { Settings, TagsMode, TagsSettings as TagsSettingsOptions } from '../../src/settings/reducers/settings';
import { TagsModeDropdown } from '../../src/tags/TagsModeDropdown';
-import { Tags } from '../../src/settings/Tags';
-import SortingDropdown from '../../src/utils/SortingDropdown';
+import { TagsSettings } from '../../src/settings/TagsSettings';
+import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
import { TagsOrder } from '../../src/tags/data/TagsListChildrenProps';
-describe('', () => {
+describe('', () => {
let wrapper: ShallowWrapper;
const setTagsSettings = jest.fn();
- const createWrapper = (tags?: TagsSettings) => {
- wrapper = shallow(({ tags })} setTagsSettings={setTagsSettings} />);
+ const createWrapper = (tags?: TagsSettingsOptions) => {
+ wrapper = shallow(({ tags })} setTagsSettings={setTagsSettings} />);
return wrapper;
};
@@ -60,7 +60,7 @@ describe('', () => {
[{ defaultOrdering: { field: 'visits', dir: 'ASC' } as TagsOrder }, { field: 'visits', dir: 'ASC' }],
])('shows expected ordering', (tags, expectedOrder) => {
const wrapper = createWrapper(tags);
- const dropdown = wrapper.find(SortingDropdown);
+ const dropdown = wrapper.find(OrderingDropdown);
expect(dropdown.prop('order')).toEqual(expectedOrder);
});
@@ -72,7 +72,7 @@ describe('', () => {
[ 'shortUrls', 'DESC' ],
])('invokes setTagsSettings when ordering changes', (field, dir) => {
const wrapper = createWrapper();
- const dropdown = wrapper.find(SortingDropdown);
+ const dropdown = wrapper.find(OrderingDropdown);
expect(setTagsSettings).not.toHaveBeenCalled();
dropdown.simulate('change', field, dir);
diff --git a/test/settings/UserInterface.test.tsx b/test/settings/UserInterfaceSettings.test.tsx
similarity index 87%
rename from test/settings/UserInterface.test.tsx
rename to test/settings/UserInterfaceSettings.test.tsx
index 55abf685..03391cee 100644
--- a/test/settings/UserInterface.test.tsx
+++ b/test/settings/UserInterfaceSettings.test.tsx
@@ -3,15 +3,15 @@ import { Mock } from 'ts-mockery';
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Settings, UiSettings } from '../../src/settings/reducers/settings';
-import { UserInterface } from '../../src/settings/UserInterface';
+import { UserInterfaceSettings } from '../../src/settings/UserInterfaceSettings';
import ToggleSwitch from '../../src/utils/ToggleSwitch';
import { Theme } from '../../src/utils/theme';
-describe('', () => {
+describe('', () => {
let wrapper: ShallowWrapper;
const setUiSettings = jest.fn();
const createWrapper = (ui?: UiSettings) => {
- wrapper = shallow(({ ui })} setUiSettings={setUiSettings} />);
+ wrapper = shallow(({ ui })} setUiSettings={setUiSettings} />);
return wrapper;
};
diff --git a/test/settings/Visits.test.tsx b/test/settings/VisitsSettings.test.tsx
similarity index 90%
rename from test/settings/Visits.test.tsx
rename to test/settings/VisitsSettings.test.tsx
index 89a73546..243fe3b6 100644
--- a/test/settings/Visits.test.tsx
+++ b/test/settings/VisitsSettings.test.tsx
@@ -1,15 +1,15 @@
import { shallow, ShallowWrapper } from 'enzyme';
import { Mock } from 'ts-mockery';
import { Settings } from '../../src/settings/reducers/settings';
-import { Visits } from '../../src/settings/Visits';
+import { VisitsSettings } from '../../src/settings/VisitsSettings';
import { SimpleCard } from '../../src/utils/SimpleCard';
import { DateIntervalSelector } from '../../src/utils/dates/DateIntervalSelector';
-describe('', () => {
+describe('', () => {
let wrapper: ShallowWrapper;
const setVisitsSettings = jest.fn();
const createWrapper = (settings: Partial = {}) => {
- wrapper = shallow((settings)} setVisitsSettings={setVisitsSettings} />);
+ wrapper = shallow((settings)} setVisitsSettings={setVisitsSettings} />);
return wrapper;
};
diff --git a/test/short-urls/ShortUrlsList.test.tsx b/test/short-urls/ShortUrlsList.test.tsx
index 3602667e..1df03e6a 100644
--- a/test/short-urls/ShortUrlsList.test.tsx
+++ b/test/short-urls/ShortUrlsList.test.tsx
@@ -4,10 +4,10 @@ import { Mock } from 'ts-mockery';
import { History, Location } from 'history';
import { match } from 'react-router';
import shortUrlsListCreator from '../../src/short-urls/ShortUrlsList';
-import { OrderableFields, ShortUrl, ShortUrlsOrder } from '../../src/short-urls/data';
+import { ShortUrlsOrderableFields, ShortUrl, ShortUrlsOrder } from '../../src/short-urls/data';
import { MercureBoundProps } from '../../src/mercure/helpers/boundToMercureHub';
import { ShortUrlsList as ShortUrlsListModel } from '../../src/short-urls/reducers/shortUrlsList';
-import SortingDropdown from '../../src/utils/SortingDropdown';
+import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
import Paginator from '../../src/short-urls/Paginator';
import { ReachableServer } from '../../src/servers/data';
import { ShortUrlListRouteParams } from '../../src/short-urls/helpers/hooks';
@@ -54,7 +54,7 @@ describe('', () => {
it('wraps expected components', () => {
expect(wrapper.find(ShortUrlsTable)).toHaveLength(1);
- expect(wrapper.find(SortingDropdown)).toHaveLength(1);
+ expect(wrapper.find(OrderingDropdown)).toHaveLength(1);
expect(wrapper.find(Paginator)).toHaveLength(1);
expect(wrapper.find(SearchBar)).toHaveLength(1);
});
@@ -75,44 +75,44 @@ describe('', () => {
});
it('invokes order icon rendering', () => {
- const renderIcon = (field: OrderableFields) =>
- (wrapper.find(ShortUrlsTable).prop('renderOrderIcon') as (field: OrderableFields) => ReactElement)(field);
+ const renderIcon = (field: ShortUrlsOrderableFields) =>
+ (wrapper.find(ShortUrlsTable).prop('renderOrderIcon') as (field: ShortUrlsOrderableFields) => ReactElement)(field);
expect(renderIcon('visits').props.currentOrder).toEqual({});
- wrapper.find(SortingDropdown).simulate('change', 'visits');
+ wrapper.find(OrderingDropdown).simulate('change', 'visits');
expect(renderIcon('visits').props.currentOrder).toEqual({ field: 'visits' });
- wrapper.find(SortingDropdown).simulate('change', 'visits', 'ASC');
+ wrapper.find(OrderingDropdown).simulate('change', 'visits', 'ASC');
expect(renderIcon('visits').props.currentOrder).toEqual({ field: 'visits', dir: 'ASC' });
});
it('handles order through table', () => {
- const orderByColumn: (field: OrderableFields) => Function = wrapper.find(ShortUrlsTable).prop('orderByColumn');
+ const orderByColumn: (field: ShortUrlsOrderableFields) => Function = wrapper.find(ShortUrlsTable).prop('orderByColumn');
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({});
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({});
orderByColumn('visits')();
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
orderByColumn('title')();
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'title', dir: 'ASC' });
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'title', dir: 'ASC' });
orderByColumn('shortCode')();
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'shortCode', dir: 'ASC' });
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'shortCode', dir: 'ASC' });
});
it('handles order through dropdown', () => {
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({});
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({});
- wrapper.find(SortingDropdown).simulate('change', 'visits', 'ASC');
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
+ wrapper.find(OrderingDropdown).simulate('change', 'visits', 'ASC');
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
- wrapper.find(SortingDropdown).simulate('change', 'shortCode', 'DESC');
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'shortCode', dir: 'DESC' });
+ wrapper.find(OrderingDropdown).simulate('change', 'shortCode', 'DESC');
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'shortCode', dir: 'DESC' });
- wrapper.find(SortingDropdown).simulate('change', undefined, undefined);
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({});
+ wrapper.find(OrderingDropdown).simulate('change', undefined, undefined);
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({});
});
it.each([
@@ -122,6 +122,6 @@ describe('', () => {
])('has expected initial ordering', (initialOrderBy, field, dir) => {
const wrapper = createWrapper(initialOrderBy);
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field, dir });
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field, dir });
});
});
diff --git a/test/short-urls/ShortUrlsTable.test.tsx b/test/short-urls/ShortUrlsTable.test.tsx
index bcbccd23..a0be282e 100644
--- a/test/short-urls/ShortUrlsTable.test.tsx
+++ b/test/short-urls/ShortUrlsTable.test.tsx
@@ -5,7 +5,7 @@ import { ShortUrlsTable as shortUrlsTableCreator } from '../../src/short-urls/Sh
import { ShortUrlsList } from '../../src/short-urls/reducers/shortUrlsList';
import { ReachableServer, SelectedServer } from '../../src/servers/data';
import { SemVer } from '../../src/utils/helpers/version';
-import { OrderableFields, SORTABLE_FIELDS } from '../../src/short-urls/data';
+import { ShortUrlsOrderableFields, SHORT_URLS_ORDERABLE_FIELDS } from '../../src/short-urls/data';
describe('', () => {
let wrapper: ShallowWrapper;
@@ -51,8 +51,8 @@ describe('', () => {
.find('thead')
.find('tr')
.find('th')
- .filterWhere((e) => e.text().includes(SORTABLE_FIELDS[orderableField as OrderableFields]));
- const sortableFields = Object.keys(SORTABLE_FIELDS).filter((sortableField) => sortableField !== 'title');
+ .filterWhere((e) => e.text().includes(SHORT_URLS_ORDERABLE_FIELDS[orderableField as ShortUrlsOrderableFields]));
+ const sortableFields = Object.keys(SHORT_URLS_ORDERABLE_FIELDS).filter((sortableField) => sortableField !== 'title');
expect.assertions(sortableFields.length);
sortableFields.forEach((sortableField) => {
diff --git a/test/tags/TagsList.test.tsx b/test/tags/TagsList.test.tsx
index 4c5848b6..1d6de35b 100644
--- a/test/tags/TagsList.test.tsx
+++ b/test/tags/TagsList.test.tsx
@@ -9,8 +9,8 @@ import { Result } from '../../src/utils/Result';
import { TagsModeDropdown } from '../../src/tags/TagsModeDropdown';
import SearchField from '../../src/utils/SearchField';
import { Settings } from '../../src/settings/reducers/settings';
-import { OrderableFields } from '../../src/tags/data/TagsListChildrenProps';
-import SortingDropdown from '../../src/utils/SortingDropdown';
+import { TagsOrderableFields } from '../../src/tags/data/TagsListChildrenProps';
+import { OrderingDropdown } from '../../src/utils/OrderingDropdown';
describe('', () => {
let wrapper: ShallowWrapper;
@@ -89,16 +89,16 @@ describe('', () => {
it('triggers ordering when sorting dropdown changes', () => {
const wrapper = createWrapper({ filteredTags: [] });
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({});
- wrapper.find(SortingDropdown).simulate('change', 'tag', 'DESC');
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'tag', dir: 'DESC' });
- wrapper.find(SortingDropdown).simulate('change', 'visits', 'ASC');
- expect(wrapper.find(SortingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({});
+ wrapper.find(OrderingDropdown).simulate('change', 'tag', 'DESC');
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'tag', dir: 'DESC' });
+ wrapper.find(OrderingDropdown).simulate('change', 'visits', 'ASC');
+ expect(wrapper.find(OrderingDropdown).prop('order')).toEqual({ field: 'visits', dir: 'ASC' });
});
it('can update current order via orderByColumn from table component', () => {
const wrapper = createWrapper({ filteredTags: [ 'foo', 'bar' ], stats: {} });
- const callOrderBy = (field: OrderableFields) => {
+ const callOrderBy = (field: TagsOrderableFields) => {
((wrapper.find(TagsTable).prop('orderByColumn') as Function)(field) as Function)();
};
diff --git a/test/utils/SortingDropdown.test.tsx b/test/utils/SortingDropdown.test.tsx
index 934bbfb7..a2c874ce 100644
--- a/test/utils/SortingDropdown.test.tsx
+++ b/test/utils/SortingDropdown.test.tsx
@@ -3,7 +3,7 @@ import { DropdownItem, DropdownToggle } from 'reactstrap';
import { identity, values } from 'ramda';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSortAmountDown as caretDownIcon } from '@fortawesome/free-solid-svg-icons';
-import SortingDropdown, { SortingDropdownProps } from '../../src/utils/SortingDropdown';
+import { OrderingDropdown, OrderingDropdownProps } from '../../src/utils/OrderingDropdown';
import { OrderDir } from '../../src/utils/helpers/ordering';
describe('', () => {
@@ -13,8 +13,8 @@ describe('', () => {
bar: 'Bar',
baz: 'Hello World',
};
- const createWrapper = (props: Partial = {}) => {
- wrapper = shallow();
+ const createWrapper = (props: Partial = {}) => {
+ wrapper = shallow();
return wrapper;
};
diff --git a/test/visits/charts/SortableBarChartCard.test.tsx b/test/visits/charts/SortableBarChartCard.test.tsx
index 338b220b..91d088c5 100644
--- a/test/visits/charts/SortableBarChartCard.test.tsx
+++ b/test/visits/charts/SortableBarChartCard.test.tsx
@@ -1,6 +1,6 @@
import { shallow, ShallowWrapper } from 'enzyme';
import { range } from 'ramda';
-import SortingDropdown from '../../../src/utils/SortingDropdown';
+import { OrderingDropdown } from '../../../src/utils/OrderingDropdown';
import PaginationDropdown from '../../../src/utils/PaginationDropdown';
import { rangeOf } from '../../../src/utils/utils';
import { OrderDir } from '../../../src/utils/helpers/ordering';
@@ -45,7 +45,7 @@ describe('', () => {
beforeEach(() => {
const wrapper = createWrapper();
- const dropdown = wrapper.renderProp('title' as never)().find(SortingDropdown);
+ const dropdown = wrapper.renderProp('title' as never)().find(OrderingDropdown);
assert = (sortName: string, sortDir: OrderDir, keys: string[], values: number[]) => {
dropdown.prop('onChange')(sortName, sortDir);