diff --git a/CHANGELOG.md b/CHANGELOG.md
index 733c2632..8bd8c4b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
+## [Unreleased]
+
+#### Added
+
+* *Nothing*
+
+#### Changed
+
+* [#205](https://github.com/shlinkio/shlink-web-client/issues/205) Replaced `jest-each` package by jet's native `test.each` function.
+
+#### Deprecated
+
+* *Nothing*
+
+#### Removed
+
+* *Nothing*
+
+#### Fixed
+
+* *Nothing*
+
+
## 2.3.1 - 2020-02-08
#### Added
diff --git a/package.json b/package.json
index e5d91d2c..2f90e280 100644
--- a/package.json
+++ b/package.json
@@ -104,7 +104,6 @@
"html-webpack-plugin": "^4.0.0-beta.8",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.9.0",
- "jest-each": "^24.9.0",
"jest-pnp-resolver": "^1.2.1",
"jest-resolve": "^24.9.0",
"mini-css-extract-plugin": "^0.8.0",
diff --git a/test/common/SimplePaginator.test.js b/test/common/SimplePaginator.test.js
index 29101786..97a083fc 100644
--- a/test/common/SimplePaginator.test.js
+++ b/test/common/SimplePaginator.test.js
@@ -1,7 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { identity } from 'ramda';
-import each from 'jest-each';
import { PaginationItem } from 'reactstrap';
import SimplePaginator, { ellipsis } from '../../src/common/SimplePaginator';
@@ -15,7 +14,7 @@ describe('', () => {
afterEach(() => wrapper && wrapper.unmount());
- each([ -3, -2, 0, 1 ]).it('renders empty when the amount of pages is smaller than 2', (pagesCount) => {
+ it.each([ -3, -2, 0, 1 ])('renders empty when the amount of pages is smaller than 2', (pagesCount) => {
expect(createWrapper(pagesCount).text()).toEqual('');
});
diff --git a/test/servers/helpers/ForServerVersion.test.js b/test/servers/helpers/ForServerVersion.test.js
index c229642a..43f486bd 100644
--- a/test/servers/helpers/ForServerVersion.test.js
+++ b/test/servers/helpers/ForServerVersion.test.js
@@ -1,6 +1,5 @@
import React from 'react';
import { mount } from 'enzyme';
-import each from 'jest-each';
import ForServerVersion from '../../../src/servers/helpers/ForServerVersion';
describe('', () => {
@@ -24,23 +23,23 @@ describe('', () => {
expect(wrapped.html()).toBeNull();
});
- each([
+ it.each([
[ '2.0.0', undefined, '1.8.3' ],
[ undefined, '1.8.0', '1.8.3' ],
[ '1.7.0', '1.8.0', '1.8.3' ],
- ]).it('does not render children when current version does not match requirements', (min, max, version) => {
+ ])('does not render children when current version does not match requirements', (min, max, version) => {
const wrapped = renderComponent(min, max, { version });
expect(wrapped.html()).toBeNull();
});
- each([
+ it.each([
[ '2.0.0', undefined, '2.8.3' ],
[ '2.0.0', undefined, '2.0.0' ],
[ undefined, '1.8.0', '1.8.0' ],
[ undefined, '1.8.0', '1.7.1' ],
[ '1.7.0', '1.8.0', '1.7.3' ],
- ]).it('renders children when current version matches requirements', (min, max, version) => {
+ ])('renders children when current version matches requirements', (min, max, version) => {
const wrapped = renderComponent(min, max, { version });
expect(wrapped.html()).toContain('Hello');
diff --git a/test/servers/reducers/selectedServer.test.js b/test/servers/reducers/selectedServer.test.js
index 93baad62..f7650f69 100644
--- a/test/servers/reducers/selectedServer.test.js
+++ b/test/servers/reducers/selectedServer.test.js
@@ -1,4 +1,3 @@
-import each from 'jest-each';
import reducer, {
selectServer,
resetSelectedServer,
@@ -44,11 +43,11 @@ describe('selectedServerReducer', () => {
afterEach(jest.clearAllMocks);
- each([
+ it.each([
[ version, version ],
[ 'latest', MAX_FALLBACK_VERSION ],
[ '%invalid_semver%', MIN_FALLBACK_VERSION ],
- ]).it('dispatches proper actions', async (serverVersion, expectedVersion) => {
+ ])('dispatches proper actions', async (serverVersion, expectedVersion) => {
const expectedSelectedServer = {
...selectedServer,
version: expectedVersion,
diff --git a/test/servers/reducers/server.test.js b/test/servers/reducers/server.test.js
index 278e3e92..f819ee34 100644
--- a/test/servers/reducers/server.test.js
+++ b/test/servers/reducers/server.test.js
@@ -1,5 +1,4 @@
import { values } from 'ramda';
-import each from 'jest-each';
import reducer, {
createServer,
deleteServer,
@@ -47,7 +46,7 @@ describe('serverReducer', () => {
expect(axios.get).not.toHaveBeenCalled();
});
- each([
+ it.each([
[
Promise.resolve({
data: [
@@ -82,7 +81,7 @@ describe('serverReducer', () => {
],
[ Promise.resolve(''), {}],
[ Promise.reject({}), {}],
- ]).it('tries to fetch servers from remote when not found locally', async (mockedValue, expectedList) => {
+ ])('tries to fetch servers from remote when not found locally', async (mockedValue, expectedList) => {
axios.get.mockReturnValue(mockedValue);
await listServers(NoListServersServiceMock, axios)()(dispatch);
diff --git a/test/short-urls/SearchBar.test.js b/test/short-urls/SearchBar.test.js
index 2d7ef01c..95b9b1d6 100644
--- a/test/short-urls/SearchBar.test.js
+++ b/test/short-urls/SearchBar.test.js
@@ -1,6 +1,5 @@
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';
@@ -62,7 +61,7 @@ describe('', () => {
expect(listShortUrlsMock).toHaveBeenCalledTimes(1);
});
- each([ 'startDateChange', 'endDateChange' ]).it('updates short URLs list when date range changes', (event) => {
+ it.each([ 'startDateChange', 'endDateChange' ])('updates short URLs list when date range changes', (event) => {
wrapper = shallow(
);
diff --git a/test/short-urls/helpers/DeleteShortUrlModal.test.js b/test/short-urls/helpers/DeleteShortUrlModal.test.js
index ed563b54..1cb4dbb1 100644
--- a/test/short-urls/helpers/DeleteShortUrlModal.test.js
+++ b/test/short-urls/helpers/DeleteShortUrlModal.test.js
@@ -1,7 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { identity } from 'ramda';
-import each from 'jest-each';
import DeleteShortUrlModal from '../../../src/short-urls/helpers/DeleteShortUrlModal';
describe('', () => {
@@ -32,7 +31,7 @@ describe('', () => {
deleteShortUrl.mockClear();
});
- each([
+ it.each([
[
{ error: 'INVALID_SHORTCODE_DELETION' },
'This short URL has received too many visits, and therefore, it cannot be deleted.',
@@ -49,7 +48,7 @@ describe('', () => {
{ type: 'INVALID_SHORTCODE_DELETION', threshold: 8 },
'This short URL has received more than 8 visits, and therefore, it cannot be deleted.',
],
- ]).it('shows threshold error message when threshold error occurs', (errorData, expectedMessage) => {
+ ])('shows threshold error message when threshold error occurs', (errorData, expectedMessage) => {
const wrapper = createWrapper({
loading: false,
error: true,
diff --git a/test/short-urls/helpers/EditMetaModal.test.js b/test/short-urls/helpers/EditMetaModal.test.js
index 471157fc..e44be7bd 100644
--- a/test/short-urls/helpers/EditMetaModal.test.js
+++ b/test/short-urls/helpers/EditMetaModal.test.js
@@ -1,7 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { FormGroup, Modal, ModalHeader } from 'reactstrap';
-import each from 'jest-each';
import EditMetaModal from '../../../src/short-urls/helpers/EditMetaModal';
describe('', () => {
@@ -40,10 +39,10 @@ describe('', () => {
expect(error).toHaveLength(0);
});
- each([
+ it.each([
[ true, 'Saving...' ],
[ false, 'Save' ],
- ]).it('renders submit button on expected state', (saving, expectedText) => {
+ ])('renders submit button on expected state', (saving, expectedText) => {
const wrapper = createWrapper({}, { saving, error: false, meta: {} });
const button = wrapper.find('[type="submit"]');
@@ -69,11 +68,11 @@ describe('', () => {
expect(editShortUrlMeta).toHaveBeenCalled();
});
- each([
+ it.each([
[ '.btn-link', 'onClick' ],
[ Modal, 'toggle' ],
[ ModalHeader, 'toggle' ],
- ]).it('resets meta when modal is toggled in any way', (componentToFind, propToCall) => {
+ ])('resets meta when modal is toggled in any way', (componentToFind, propToCall) => {
const wrapper = createWrapper({}, { saving: false, error: false, meta: {} });
const component = wrapper.find(componentToFind);
diff --git a/test/short-urls/helpers/EditTagsModal.test.js b/test/short-urls/helpers/EditTagsModal.test.js
index 07243442..f9c6ffb3 100644
--- a/test/short-urls/helpers/EditTagsModal.test.js
+++ b/test/short-urls/helpers/EditTagsModal.test.js
@@ -1,7 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Modal } from 'reactstrap';
-import each from 'jest-each';
import createEditTagsModal from '../../../src/short-urls/helpers/EditTagsModal';
describe('', () => {
@@ -76,7 +75,7 @@ describe('', () => {
expect(saveBtn.text()).toEqual('Saving tags...');
});
- each([[ undefined ], [ null ], [ 'example.com' ]]).it('saves tags when save button is clicked', (domain, done) => {
+ it.each([[ undefined ], [ null ], [ 'example.com' ]])('saves tags when save button is clicked', (domain, done) => {
const wrapper = createWrapper({
shortCode,
tags: [],
diff --git a/test/short-urls/helpers/ShortUrlVisitsCount.test.js b/test/short-urls/helpers/ShortUrlVisitsCount.test.js
index 3a375fd9..0e9716f7 100644
--- a/test/short-urls/helpers/ShortUrlVisitsCount.test.js
+++ b/test/short-urls/helpers/ShortUrlVisitsCount.test.js
@@ -1,7 +1,6 @@
import React from 'react';
import { shallow } from 'enzyme';
import { UncontrolledTooltip } from 'reactstrap';
-import each from 'jest-each';
import ShortUrlVisitsCount from '../../../src/short-urls/helpers/ShortUrlVisitsCount';
describe('', () => {
@@ -15,7 +14,7 @@ describe('', () => {
afterEach(() => wrapper && wrapper.unmount());
- each([ undefined, {}]).it('just returns visits when no maxVisits is provided', (meta) => {
+ it.each([ undefined, {}])('just returns visits when no maxVisits is provided', (meta) => {
const visitsCount = 45;
const wrapper = createWrapper(visitsCount, { meta });
const maxVisitsHelper = wrapper.find('.short-urls-visits-count__max-visits-control');
diff --git a/test/short-urls/helpers/VisitStatsLink.test.js b/test/short-urls/helpers/VisitStatsLink.test.js
index dd7a2ec6..f029304e 100644
--- a/test/short-urls/helpers/VisitStatsLink.test.js
+++ b/test/short-urls/helpers/VisitStatsLink.test.js
@@ -1,6 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
-import each from 'jest-each';
import { Link } from 'react-router-dom';
import VisitStatsLink from '../../../src/short-urls/helpers/VisitStatsLink';
@@ -9,14 +8,14 @@ describe('', () => {
afterEach(() => wrapper && wrapper.unmount());
- each([
+ it.each([
[ undefined, undefined ],
[ null, null ],
[{}, null ],
[{}, undefined ],
[ null, {}],
[ undefined, {}],
- ]).it('only renders a plan span when either server or short URL are not set', (selectedServer, shortUrl) => {
+ ])('only renders a plan span when either server or short URL are not set', (selectedServer, shortUrl) => {
wrapper = shallow(Something);
const link = wrapper.find(Link);
@@ -24,14 +23,14 @@ describe('', () => {
expect(wrapper.html()).toEqual('Something');
});
- each([
+ it.each([
[{ id: '1' }, { shortCode: 'abc123' }, '/server/1/short-code/abc123/visits' ],
[
{ id: '3' },
{ shortCode: 'def456', domain: 'example.com' },
'/server/3/short-code/def456/visits?domain=example.com',
],
- ]).it('renders link with expected query when', (selectedServer, shortUrl, expectedLink) => {
+ ])('renders link with expected query when', (selectedServer, shortUrl, expectedLink) => {
wrapper = shallow(Something);
const link = wrapper.find(Link);
const to = link.prop('to');
diff --git a/test/short-urls/reducers/shortUrlDeletion.test.js b/test/short-urls/reducers/shortUrlDeletion.test.js
index d1b142ce..ad5b2649 100644
--- a/test/short-urls/reducers/shortUrlDeletion.test.js
+++ b/test/short-urls/reducers/shortUrlDeletion.test.js
@@ -1,4 +1,3 @@
-import each from 'jest-each';
import reducer, {
DELETE_SHORT_URL_ERROR,
DELETE_SHORT_URL_START,
@@ -60,9 +59,9 @@ describe('shortUrlDeletionReducer', () => {
getState.mockClear();
});
- each(
+ it.each(
[[ undefined ], [ null ], [ 'example.com' ]]
- ).it('dispatches proper actions if API client request succeeds', async (domain) => {
+ )('dispatches proper actions if API client request succeeds', async (domain) => {
const apiClientMock = {
deleteShortUrl: jest.fn(() => ''),
};
diff --git a/test/short-urls/reducers/shortUrlMeta.test.js b/test/short-urls/reducers/shortUrlMeta.test.js
index 92d82066..8775d22d 100644
--- a/test/short-urls/reducers/shortUrlMeta.test.js
+++ b/test/short-urls/reducers/shortUrlMeta.test.js
@@ -1,5 +1,4 @@
import moment from 'moment';
-import each from 'jest-each';
import reducer, {
EDIT_SHORT_URL_META_START,
EDIT_SHORT_URL_META_ERROR,
@@ -57,7 +56,7 @@ describe('shortUrlMetaReducer', () => {
afterEach(jest.clearAllMocks);
- each([[ undefined ], [ null ], [ 'example.com' ]]).it('dispatches metadata on success', async (domain) => {
+ it.each([[ undefined ], [ null ], [ 'example.com' ]])('dispatches metadata on success', async (domain) => {
await editShortUrlMeta(buildShlinkApiClient)(shortCode, domain, meta)(dispatch);
expect(buildShlinkApiClient).toHaveBeenCalledTimes(1);
diff --git a/test/short-urls/reducers/shortUrlTags.test.js b/test/short-urls/reducers/shortUrlTags.test.js
index 169c5607..967953c8 100644
--- a/test/short-urls/reducers/shortUrlTags.test.js
+++ b/test/short-urls/reducers/shortUrlTags.test.js
@@ -1,4 +1,3 @@
-import each from 'jest-each';
import reducer, {
EDIT_SHORT_URL_TAGS_ERROR,
EDIT_SHORT_URL_TAGS_START,
@@ -61,7 +60,7 @@ describe('shortUrlTagsReducer', () => {
dispatch.mockReset();
});
- each([[ undefined ], [ null ], [ 'example.com' ]]).it('dispatches normalized tags on success', async (domain) => {
+ it.each([[ undefined ], [ null ], [ 'example.com' ]])('dispatches normalized tags on success', async (domain) => {
const normalizedTags = [ 'bar', 'foo' ];
updateShortUrlTags.mockResolvedValue(normalizedTags);
diff --git a/test/utils/services/ShlinkApiClient.test.js b/test/utils/services/ShlinkApiClient.test.js
index 8cda6271..1f35d268 100644
--- a/test/utils/services/ShlinkApiClient.test.js
+++ b/test/utils/services/ShlinkApiClient.test.js
@@ -1,4 +1,3 @@
-import each from 'jest-each';
import ShlinkApiClient from '../../../src/utils/services/ShlinkApiClient';
describe('ShlinkApiClient', () => {
@@ -73,7 +72,7 @@ describe('ShlinkApiClient', () => {
});
describe('getShortUrl', () => {
- each(shortCodesWithDomainCombinations).it('properly returns short URL', async (shortCode, domain) => {
+ it.each(shortCodesWithDomainCombinations)('properly returns short URL', async (shortCode, domain) => {
const expectedShortUrl = { foo: 'bar' };
const axiosSpy = jest.fn(createAxiosMock({
data: expectedShortUrl,
@@ -92,7 +91,7 @@ describe('ShlinkApiClient', () => {
});
describe('updateShortUrlTags', () => {
- each(shortCodesWithDomainCombinations).it('properly updates short URL tags', async (shortCode, domain) => {
+ it.each(shortCodesWithDomainCombinations)('properly updates short URL tags', async (shortCode, domain) => {
const expectedTags = [ 'foo', 'bar' ];
const axiosSpy = jest.fn(createAxiosMock({
data: { tags: expectedTags },
@@ -111,7 +110,7 @@ describe('ShlinkApiClient', () => {
});
describe('updateShortUrlMeta', () => {
- each(shortCodesWithDomainCombinations).it('properly updates short URL meta', async (shortCode, domain) => {
+ it.each(shortCodesWithDomainCombinations)('properly updates short URL meta', async (shortCode, domain) => {
const expectedMeta = {
maxVisits: 50,
validSince: '2025-01-01T10:00:00+01:00',
@@ -181,7 +180,7 @@ describe('ShlinkApiClient', () => {
});
describe('deleteShortUrl', () => {
- each(shortCodesWithDomainCombinations).it('properly deletes provided short URL', async (shortCode, domain) => {
+ it.each(shortCodesWithDomainCombinations)('properly deletes provided short URL', async (shortCode, domain) => {
const axiosSpy = jest.fn(createAxiosMock({}));
const { deleteShortUrl } = new ShlinkApiClient(axiosSpy);