mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Fixed tests
This commit is contained in:
parent
8223f0fd64
commit
7db222664d
4 changed files with 39 additions and 24 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -5340,7 +5340,7 @@
|
||||||
},
|
},
|
||||||
"discontinuous-range": {
|
"discontinuous-range": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz",
|
"resolved": "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz",
|
||||||
"integrity": "sha1-44Mx8IRLukm5qctxx3FYWqsbxlo=",
|
"integrity": "sha1-44Mx8IRLukm5qctxx3FYWqsbxlo=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -9346,7 +9346,7 @@
|
||||||
},
|
},
|
||||||
"is-subset": {
|
"is-subset": {
|
||||||
"version": "0.1.1",
|
"version": "0.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz",
|
"resolved": "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz",
|
||||||
"integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=",
|
"integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -10557,13 +10557,13 @@
|
||||||
},
|
},
|
||||||
"lodash.escape": {
|
"lodash.escape": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-4.0.1.tgz",
|
"resolved": "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-4.0.1.tgz",
|
||||||
"integrity": "sha1-yQRGkMIeBClL6qUXcS/e0fqI3pg=",
|
"integrity": "sha1-yQRGkMIeBClL6qUXcS/e0fqI3pg=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"lodash.flattendeep": {
|
"lodash.flattendeep": {
|
||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
|
"resolved": "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
|
||||||
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
|
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -10575,7 +10575,7 @@
|
||||||
},
|
},
|
||||||
"lodash.isequal": {
|
"lodash.isequal": {
|
||||||
"version": "4.5.0",
|
"version": "4.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
|
"resolved": "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
|
||||||
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=",
|
"integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -13817,7 +13817,7 @@
|
||||||
},
|
},
|
||||||
"railroad-diagrams": {
|
"railroad-diagrams": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz",
|
"resolved": "https://registry.yarnpkg.com/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz",
|
||||||
"integrity": "sha1-635iZ1SN3t+4mcG5Dlc3RVnN234=",
|
"integrity": "sha1-635iZ1SN3t+4mcG5Dlc3RVnN234=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
@ -14977,7 +14977,7 @@
|
||||||
},
|
},
|
||||||
"rst-selector-parser": {
|
"rst-selector-parser": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/rst-selector-parser/-/rst-selector-parser-2.2.3.tgz",
|
"resolved": "https://registry.yarnpkg.com/rst-selector-parser/-/rst-selector-parser-2.2.3.tgz",
|
||||||
"integrity": "sha1-gbIw6i/MYGbInjRy3nlChdmwPZE=",
|
"integrity": "sha1-gbIw6i/MYGbInjRy3nlChdmwPZE=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
|
|
@ -20,13 +20,14 @@ describe('<App />', () => {
|
||||||
it('renders app main routes', () => {
|
it('renders app main routes', () => {
|
||||||
const routes = wrapper.find(Route);
|
const routes = wrapper.find(Route);
|
||||||
const expectedPaths = [
|
const expectedPaths = [
|
||||||
'/server/create',
|
|
||||||
'/',
|
'/',
|
||||||
|
'/server/create',
|
||||||
|
'/server/:serverId/edit',
|
||||||
'/server/:serverId',
|
'/server/:serverId',
|
||||||
];
|
];
|
||||||
|
|
||||||
expect.assertions(expectedPaths.length + 1);
|
expect.assertions(expectedPaths.length + 1);
|
||||||
expect(routes).toHaveLength(4);
|
expect(routes).toHaveLength(expectedPaths.length + 1);
|
||||||
expectedPaths.forEach((path, index) => {
|
expectedPaths.forEach((path, index) => {
|
||||||
expect(routes.at(index).prop('path')).toEqual(path);
|
expect(routes.at(index).prop('path')).toEqual(path);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,35 +1,49 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { ServerError } from '../../../src/servers/helpers/ServerError';
|
import { ServerError as createServerError } from '../../../src/servers/helpers/ServerError';
|
||||||
|
|
||||||
describe('<ServerError />', () => {
|
describe('<ServerError />', () => {
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
const selectedServer = { id: '' };
|
||||||
|
const ServerError = createServerError(() => '');
|
||||||
|
|
||||||
afterEach(() => wrapper && wrapper.unmount());
|
afterEach(() => wrapper && wrapper.unmount());
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
'not-found',
|
'not-found',
|
||||||
[ 'Could not find this Shlink server.' ],
|
{
|
||||||
'These are the Shlink servers',
|
'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,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'not-reachable',
|
'not-reachable',
|
||||||
[
|
{
|
||||||
'Oops! Could not connect to this Shlink server.',
|
'Could not find this Shlink server.': false,
|
||||||
'Make sure you have internet connection, and the server is properly configured and on-line.',
|
'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,
|
||||||
'These are the other Shlink servers',
|
'Alternatively, if you think you may have miss-configured this server': true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
])('renders expected information based on type', (type, expectedTitleParts, expectedBody) => {
|
])('renders expected information for type "%s"', (type, textsToFind) => {
|
||||||
wrapper = shallow(<BrowserRouter><ServerError type={type} servers={{ list: [] }} /></BrowserRouter>);
|
wrapper = shallow(
|
||||||
|
<BrowserRouter>
|
||||||
|
<ServerError type={type} servers={{ list: [] }} selectedServer={selectedServer} />
|
||||||
|
</BrowserRouter>
|
||||||
|
);
|
||||||
const wrapperText = wrapper.html();
|
const wrapperText = wrapper.html();
|
||||||
const textsToFind = [ ...expectedTitleParts, ...expectedBody ];
|
const textPairs = Object.entries(textsToFind);
|
||||||
|
|
||||||
expect.assertions(textsToFind.length);
|
textPairs.forEach(([ text, shouldBeFound ]) => {
|
||||||
textsToFind.forEach((text) => {
|
if (shouldBeFound) {
|
||||||
expect(wrapperText).toContain(text);
|
expect(wrapperText).toContain(text);
|
||||||
|
} else {
|
||||||
|
expect(wrapperText).not.toContain(text);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe('selectedServerReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches error when health endpoint fails', async () => {
|
it('dispatches error when health endpoint fails', async () => {
|
||||||
const expectedSelectedServer = { serverNotReachable: true };
|
const expectedSelectedServer = { ...selectedServer, serverNotReachable: true };
|
||||||
|
|
||||||
apiClientMock.health.mockRejectedValue({});
|
apiClientMock.health.mockRejectedValue({});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue