From f21f7f9708b9570bd13d2836d86ff59dc40c5c11 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Tue, 29 Dec 2020 13:21:17 -0500 Subject: [PATCH] #17 Tests for SemanticField, MediaEmbed components --- .../SemanticField/SemanticField.test.js | 20 +++++++++++++++++++ .../SlateMediaEmbedElement.js | 1 + .../SlateMediaEmbedElement.test.js | 19 ++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/components/SemanticField/SemanticField.test.js create mode 100644 src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.test.js diff --git a/src/components/SemanticField/SemanticField.test.js b/src/components/SemanticField/SemanticField.test.js new file mode 100644 index 00000000..e1cfefbc --- /dev/null +++ b/src/components/SemanticField/SemanticField.test.js @@ -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( + + + , + ); + const field = getByRole('textbox'); + expect(field).toBeInTheDocument(); +}); diff --git a/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.js b/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.js index 032eb576..c3c962a7 100644 --- a/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.js +++ b/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.js @@ -15,6 +15,7 @@ const SlateMediaEmbedElement = ({ title="embed" src={`${url}`} frameBorder="0" + data-testid="slate-iframe" /> diff --git a/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.test.js b/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.test.js new file mode 100644 index 00000000..f68b7e54 --- /dev/null +++ b/src/components/SlateMediaEmbedElement/SlateMediaEmbedElement.test.js @@ -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( + + + , + ); + const elem = getByTestId('slate-iframe'); + expect(elem).toBeInTheDocument(); +});