diff --git a/test/servers/helpers/ServerError.test.tsx b/test/servers/helpers/ServerError.test.tsx
index 014d6ff3..88847c39 100644
--- a/test/servers/helpers/ServerError.test.tsx
+++ b/test/servers/helpers/ServerError.test.tsx
@@ -1,49 +1,43 @@
-import { shallow, ShallowWrapper } from 'enzyme';
-import { BrowserRouter } from 'react-router-dom';
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
import { Mock } from 'ts-mockery';
import { ServerError as createServerError } from '../../../src/servers/helpers/ServerError';
import { NonReachableServer, NotFoundServer } from '../../../src/servers/data';
describe('', () => {
- let wrapper: ShallowWrapper;
const ServerError = createServerError(() => null);
- afterEach(() => wrapper?.unmount());
-
it.each([
[
Mock.all(),
{
- 'Could not find this Shlink server.': true,
- 'Oops! Could not connect to this Shlink server.': false,
- 'Make sure you have internet connection, and the server is properly configured and on-line.': false,
- 'Alternatively, if you think you may have miss-configured this server': false,
+ found: ['Could not find this Shlink server.'],
+ notFound: [
+ 'Oops! Could not connect to this Shlink server.',
+ 'Make sure you have internet connection, and the server is properly configured and on-line.',
+ /^Alternatively, if you think you may have miss-configured this server/,
+ ],
},
],
[
Mock.of({ id: 'abc123' }),
{
- 'Could not find this Shlink server.': false,
- 'Oops! Could not connect to this Shlink server.': true,
- 'Make sure you have internet connection, and the server is properly configured and on-line.': true,
- 'Alternatively, if you think you may have miss-configured this server': true,
+ found: [
+ 'Oops! Could not connect to this Shlink server.',
+ 'Make sure you have internet connection, and the server is properly configured and on-line.',
+ /^Alternatively, if you think you may have miss-configured this server/,
+ ],
+ notFound: ['Could not find this Shlink server.'],
},
],
- ])('renders expected information based on provided server type', (selectedServer, textsToFind) => {
- wrapper = shallow(
-
+ ])('renders expected information based on provided server type', (selectedServer, { found, notFound }) => {
+ render(
+
- ,
+ ,
);
- const wrapperText = wrapper.html();
- const textPairs = Object.entries(textsToFind);
- textPairs.forEach(([text, shouldBeFound]) => {
- if (shouldBeFound) {
- expect(wrapperText).toContain(text);
- } else {
- expect(wrapperText).not.toContain(text);
- }
- });
+ found.forEach((text) => expect(screen.getByText(text)).toBeInTheDocument());
+ notFound.forEach((text) => expect(screen.queryByText(text)).not.toBeInTheDocument());
});
});