import React from 'react'; import { mount } from 'enzyme'; import ForServerVersion from '../../../src/servers/helpers/ForServerVersion'; describe('', () => { let wrapped; const renderComponent = (minVersion, maxVersion, selectedServer) => { wrapped = mount( Hello ); return wrapped; }; afterEach(() => wrapped && wrapped.unmount()); it('does not render children when current server is empty', () => { const wrapped = renderComponent('1'); expect(wrapped.html()).toBeNull(); }); it.each([ [ '2.0.0', undefined, '1.8.3' ], [ undefined, '1.8.0', '1.8.3' ], [ '1.7.0', '1.8.0', '1.8.3' ], ])('does not render children when current version does not match requirements', (min, max, version) => { const wrapped = renderComponent(min, max, { version }); expect(wrapped.html()).toBeNull(); }); it.each([ [ '2.0.0', undefined, '2.8.3' ], [ '2.0.0', undefined, '2.0.0' ], [ undefined, '1.8.0', '1.8.0' ], [ undefined, '1.8.0', '1.7.1' ], [ '1.7.0', '1.8.0', '1.7.3' ], ])('renders children when current version matches requirements', (min, max, version) => { const wrapped = renderComponent(min, max, { version }); expect(wrapped.html()).toContain('Hello'); }); });