From 83cb81fec302ed76114a0e6b28731b5a7c3a34ae Mon Sep 17 00:00:00 2001 From: Mike Wu Date: Thu, 17 Aug 2023 18:08:46 +1000 Subject: [PATCH] Refactor --- .../Story/StoryPanel/StoryBodySpec.tsx | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/test/ReactViews/Story/StoryPanel/StoryBodySpec.tsx b/test/ReactViews/Story/StoryPanel/StoryBodySpec.tsx index 9179e47608e..0760a3a086e 100644 --- a/test/ReactViews/Story/StoryPanel/StoryBodySpec.tsx +++ b/test/ReactViews/Story/StoryPanel/StoryBodySpec.tsx @@ -1,11 +1,15 @@ import React from "react"; import StoryBody from "../../../../lib/ReactViews/Story/StoryPanel/StoryBody"; import { act } from "react-dom/test-utils"; -import TestRenderer, { ReactTestInstance, create } from "react-test-renderer"; -import Box from "../../../../lib/Styled/Box"; -import { exp } from "protomaps"; +import { + ReactTestInstance, + ReactTestRenderer, + create +} from "react-test-renderer"; describe("StoryBody", function () { + let testRenderer: ReactTestRenderer; + it("should include embedded video using allowed tag and ignore unallowed attributes", function () { const theStory = { id: "some id", @@ -13,14 +17,8 @@ describe("StoryBody", function () { text: 'Story with video. ' }; - let testRenderer: ReturnType = TestRenderer.create( - - ); - act(() => { - testRenderer = TestRenderer.create( - - ); + testRenderer = create(); }); const storyBody = testRenderer.root.findAllByType(StoryBody); @@ -33,10 +31,11 @@ describe("StoryBody", function () { ).children[0] as ReactTestInstance ).children[0] as ReactTestInstance; - const theIframeInstance = theInstance.children[1] as ReactTestInstance; - expect(theInstance.children.length === 2); + expect(theInstance.children[0] as string).toEqual("Story with video. "); + + const theIframeInstance = theInstance.children[1] as ReactTestInstance; expect(theIframeInstance.type).toBe("iframe"); expect(theIframeInstance.props.title).toBe(undefined); expect(theIframeInstance.props.src).toBe("https://some.video.link"); @@ -51,14 +50,8 @@ describe("StoryBody", function () { text: 'Story with video. ' }; - let testRenderer: ReturnType = TestRenderer.create( - - ); - act(() => { - testRenderer = TestRenderer.create( - - ); + testRenderer = create(); }); const storyBody = testRenderer.root.findAllByType(StoryBody);