Skip to content

Commit

Permalink
#17 Tests for SemanticField, MediaEmbed components
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 29, 2020
1 parent cc8858f commit f21f7f9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/SemanticField/SemanticField.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @jest-environment jsdom
*/

import { render } from '@testing-library/react';
import { Formik } from 'formik';
import SemanticField from './SemanticField';

test('renders semantic field', async () => {
const { getByRole } = render(
<Formik>
<SemanticField
component="input"
type="text"
/>
</Formik>,
);
const field = getByRole('textbox');
expect(field).toBeInTheDocument();
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const SlateMediaEmbedElement = ({
title="embed"
src={`${url}`}
frameBorder="0"
data-testid="slate-iframe"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @jest-environment jsdom
*/

import { render } from '@testing-library/react';
import { Formik } from 'formik';
import SlateMediaEmbedElement from './SlateMediaEmbedElement';

test('renders slate media embed element', async () => {
const { getByTestId } = render(
<Formik>
<SlateMediaEmbedElement
element={{ url: 'https://www.youtube.com/watch?v=dGxZ4K-J5YE' }}
/>
</Formik>,
);
const elem = getByTestId('slate-iframe');
expect(elem).toBeInTheDocument();
});

0 comments on commit f21f7f9

Please sign in to comment.