From 00f154ef4e5ef35a2d22e7d30795a18db4b00bf9 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 6 May 2022 21:01:44 +0200 Subject: [PATCH] Migrated ShlinkVersionsContainer test to react testing library --- test/common/ShlinkVersionsContainer.test.tsx | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/test/common/ShlinkVersionsContainer.test.tsx b/test/common/ShlinkVersionsContainer.test.tsx index f4e67731..d264051d 100644 --- a/test/common/ShlinkVersionsContainer.test.tsx +++ b/test/common/ShlinkVersionsContainer.test.tsx @@ -1,26 +1,19 @@ -import { shallow, ShallowWrapper } from 'enzyme'; +import { render } from '@testing-library/react'; import { Mock } from 'ts-mockery'; import ShlinkVersionsContainer from '../../src/common/ShlinkVersionsContainer'; import { SelectedServer } from '../../src/servers/data'; import { Sidebar } from '../../src/common/reducers/sidebar'; describe('', () => { - let wrapper: ShallowWrapper; - - const createWrapper = (sidebar: Sidebar) => { - wrapper = shallow(()} sidebar={sidebar} />); - - return wrapper; - }; - - afterEach(() => wrapper?.unmount()); + const setUp = (sidebar: Sidebar) => render( + ()} sidebar={sidebar} />, + ); it.each([ [{ sidebarPresent: false }, 'text-center'], [{ sidebarPresent: true }, 'text-center shlink-versions-container--with-sidebar'], ])('renders proper col classes based on sidebar status', (sidebar, expectedClasses) => { - const wrapper = createWrapper(sidebar); - - expect(wrapper.find('div').prop('className')).toEqual(`${expectedClasses}`); + const { container } = setUp(sidebar); + expect(container.firstChild).toHaveAttribute('class', `${expectedClasses}`); }); });