From c8cf75fa286434a2e3313c3e5fbac4dcf371a80e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 8 Mar 2020 13:04:21 +0100 Subject: [PATCH] Created ServerError test --- test/servers/helpers/ServerError.test.js | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/servers/helpers/ServerError.test.js diff --git a/test/servers/helpers/ServerError.test.js b/test/servers/helpers/ServerError.test.js new file mode 100644 index 00000000..1e9d7417 --- /dev/null +++ b/test/servers/helpers/ServerError.test.js @@ -0,0 +1,35 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { BrowserRouter } from 'react-router-dom'; +import { ServerError } from '../../../src/servers/helpers/ServerError'; + +describe('', () => { + let wrapper; + + afterEach(() => wrapper && wrapper.unmount()); + + it.each([ + [ + 'not-found', + [ 'Could not find this Shlink server.' ], + 'These are the Shlink servers', + ], + [ + 'not-reachable', + [ + 'Oops! Could not connect to this Shlink server.', + 'Make sure you have internet connection, and the server is properly configured and on-line.', + ], + 'These are the other Shlink servers', + ], + ])('renders expected information based on type', (type, expectedTitleParts, expectedBody) => { + wrapper = shallow(); + const wrapperText = wrapper.html(); + const textsToFind = [ ...expectedTitleParts, ...expectedBody ]; + + expect.assertions(textsToFind.length); + textsToFind.forEach((text) => { + expect(wrapperText).toContain(text); + }); + }); +});