From 73e3f42614ea34aaa88a136a05468219bb6bdc48 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 5 Mar 2020 13:55:39 +0100 Subject: [PATCH] Added ShlinkVersions test --- test/common/ShlinkVersions.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/common/ShlinkVersions.test.js diff --git a/test/common/ShlinkVersions.test.js b/test/common/ShlinkVersions.test.js new file mode 100644 index 00000000..685158b0 --- /dev/null +++ b/test/common/ShlinkVersions.test.js @@ -0,0 +1,26 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import ShlinkVersions from '../../src/common/ShlinkVersions'; + +describe('', () => { + let wrapper; + const createWrapper = (props) => { + wrapper = shallow(); + + return wrapper; + }; + + afterEach(() => wrapper && wrapper.unmount()); + + it.each([ + [ '1.2.3', 'foo', 'Client: v1.2.3 - Server: foo' ], + [ 'foo', '1.2.3', 'Client: latest - Server: 1.2.3' ], + [ 'latest', 'latest', 'Client: latest - Server: latest' ], + [ '5.5.0', '0.2.8', 'Client: v5.5.0 - Server: 0.2.8' ], + [ 'not-semver', 'something', 'Client: latest - Server: something' ], + ])('displays expected versions', (clientVersion, printableVersion, expected) => { + const wrapper = createWrapper({ clientVersion, selectedServer: { printableVersion } }); + + expect(wrapper.text()).toEqual(expected); + }); +});