From c1ae3fe5fab6ceff66eb628731b5fe83c68e911d Mon Sep 17 00:00:00 2001 From: bendtherules Date: Sun, 21 Jul 2019 09:19:10 +0530 Subject: [PATCH] Fix test/utils - Allow mounting string type of elements --- test/utils/mount-in-enzyme.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/utils/mount-in-enzyme.tsx b/test/utils/mount-in-enzyme.tsx index e613ad0..4675d0f 100644 --- a/test/utils/mount-in-enzyme.tsx +++ b/test/utils/mount-in-enzyme.tsx @@ -1,9 +1,9 @@ import * as React from "react"; import { mount } from "enzyme"; -import { FiberNode } from '../../src/mocked-types'; +import { FiberNode } from "../../src/mocked-types"; export class RootNodeNotFoundError extends Error { - static message = `Couldn't find root node. This might occur if render has become async` + static message = `Couldn't find root node. This might occur if render has become async`; constructor() { super(RootNodeNotFoundError.message); this.name = "RootNodeNotFoundError"; @@ -11,7 +11,7 @@ export class RootNodeNotFoundError extends Error { } export function mountAndGetRootNode( - SomeComponentClass: typeof React.Component, + SomeComponentClass: (typeof React.Component) | string, container: HTMLElement ) { const rootRef = React.createRef(); @@ -23,7 +23,8 @@ export function mountAndGetRootNode( throw new RootNodeNotFoundError(); } - const rootNode = ((rootRef.current as any)._reactInternalFiber as FiberNode).child; + const rootNode = ((rootRef.current as any)._reactInternalFiber as FiberNode) + .child; if (rootNode === null) { throw new RootNodeNotFoundError();