2020-03-05 15:55:39 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import ShlinkVersions from '../../src/common/ShlinkVersions';
|
|
|
|
|
|
|
|
describe('<ShlinkVersions />', () => {
|
|
|
|
let wrapper;
|
|
|
|
const createWrapper = (props) => {
|
|
|
|
wrapper = shallow(<ShlinkVersions {...props} />);
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => wrapper && wrapper.unmount());
|
|
|
|
|
|
|
|
it.each([
|
2020-07-09 18:34:23 +03:00
|
|
|
[ '1.2.3', 'foo', 'v1.2.3', 'foo' ],
|
|
|
|
[ 'foo', '1.2.3', 'latest', '1.2.3' ],
|
|
|
|
[ 'latest', 'latest', 'latest', 'latest' ],
|
|
|
|
[ '5.5.0', '0.2.8', 'v5.5.0', '0.2.8' ],
|
|
|
|
[ 'not-semver', 'something', 'latest', 'something' ],
|
|
|
|
])('displays expected versions', (clientVersion, printableVersion, expectedClientVersion, expectedServerVersion) => {
|
2020-03-05 15:55:39 +03:00
|
|
|
const wrapper = createWrapper({ clientVersion, selectedServer: { printableVersion } });
|
2020-07-09 18:34:23 +03:00
|
|
|
const links = wrapper.find('VersionLink');
|
|
|
|
const clientLink = links.at(0);
|
|
|
|
const serverLink = links.at(1);
|
2020-03-05 15:55:39 +03:00
|
|
|
|
2020-07-09 18:34:23 +03:00
|
|
|
expect(clientLink.prop("project")).toEqual('shlink-web-client');
|
|
|
|
expect(clientLink.prop("version")).toEqual(expectedClientVersion);
|
|
|
|
expect(serverLink.prop("project")).toEqual('shlink');
|
|
|
|
expect(serverLink.prop("version")).toEqual(expectedServerVersion);
|
2020-03-05 15:55:39 +03:00
|
|
|
});
|
|
|
|
});
|