diff --git a/src/short-urls/CreateShortUrl.tsx b/src/short-urls/CreateShortUrl.tsx index a13b75cf..8da5a480 100644 --- a/src/short-urls/CreateShortUrl.tsx +++ b/src/short-urls/CreateShortUrl.tsx @@ -55,7 +55,6 @@ export const CreateShortUrl = ( mode={basicMode ? 'create-basic' : 'create'} onSave={async (data: ShortUrlData) => { resetCreateShortUrl(); - return createShortUrl(data); }} /> diff --git a/test/short-urls/CreateShortUrl.test.tsx b/test/short-urls/CreateShortUrl.test.tsx index 43dfdf90..553d1a65 100644 --- a/test/short-urls/CreateShortUrl.test.tsx +++ b/test/short-urls/CreateShortUrl.test.tsx @@ -1,38 +1,30 @@ -import { shallow, ShallowWrapper } from 'enzyme'; +import { render, screen } from '@testing-library/react'; import { Mock } from 'ts-mockery'; import { CreateShortUrl as createShortUrlsCreator } from '../../src/short-urls/CreateShortUrl'; import { ShortUrlCreation } from '../../src/short-urls/reducers/shortUrlCreation'; import { Settings } from '../../src/settings/reducers/settings'; describe('', () => { - let wrapper: ShallowWrapper; - const ShortUrlForm = () => null; - const CreateShortUrlResult = () => null; + const ShortUrlForm = () => ShortUrlForm; + const CreateShortUrlResult = () => CreateShortUrlResult; const shortUrlCreation = { validateUrls: true }; const shortUrlCreationResult = Mock.all(); const createShortUrl = jest.fn(async () => Promise.resolve()); + const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult); + const setUp = () => render( + {}} + settings={Mock.of({ shortUrlCreation })} + />, + ); - beforeEach(() => { - const CreateShortUrl = createShortUrlsCreator(ShortUrlForm, CreateShortUrlResult); + it('renders computed initial state', () => { + setUp(); - wrapper = shallow( - {}} - settings={Mock.of({ shortUrlCreation })} - />, - ); - }); - afterEach(() => wrapper.unmount()); - afterEach(jest.clearAllMocks); - - it('renders a ShortUrlForm with a computed initial state', () => { - const form = wrapper.find(ShortUrlForm); - const result = wrapper.find(CreateShortUrlResult); - - expect(form).toHaveLength(1); - expect(result).toHaveLength(1); + expect(screen.getByText('ShortUrlForm')).toBeInTheDocument(); + expect(screen.getByText('CreateShortUrlResult')).toBeInTheDocument(); }); });