From e2154b7d4a3fdc9827872c44645d92be4bfd756f Mon Sep 17 00:00:00 2001 From: nbarlowATI Date: Mon, 21 Mar 2022 17:33:45 +0000 Subject: [PATCH] add some tests --- .../src/components/tests/ItemViewer.test.js | 9 ++++++--- frontend/src/components/tests/Mermaid.test.js | 17 ++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/tests/ItemViewer.test.js b/frontend/src/components/tests/ItemViewer.test.js index 61104cce..3dd5c09d 100644 --- a/frontend/src/components/tests/ItemViewer.test.js +++ b/frontend/src/components/tests/ItemViewer.test.js @@ -1,6 +1,7 @@ import { render, screen, waitFor } from "@testing-library/react"; import "@testing-library/jest-dom"; import "regenerator-runtime/runtime"; +import { act } from "react-dom/test-utils"; import React from "react"; import { Link } from "react-router-dom"; import ItemViewer from "../ItemViewer.js"; @@ -19,7 +20,9 @@ global.fetch = jest.fn(() => }) ); -test("renders item viewer layer", async () => { - render(); - // await waitFor(() => expect(screen.findByText("Loading")).toBeInTheDocument()); +test("renders item viewer layer", () => { + act(() => { + render(); + }); + expect(screen.getByText("Name")).toBeInTheDocument(); }); diff --git a/frontend/src/components/tests/Mermaid.test.js b/frontend/src/components/tests/Mermaid.test.js index c38bcea3..83ff5233 100644 --- a/frontend/src/components/tests/Mermaid.test.js +++ b/frontend/src/components/tests/Mermaid.test.js @@ -1,14 +1,13 @@ -import { render, screen } from "@testing-library/react"; +import { render, screen, waitFor } from "@testing-library/react"; import React from "react"; -import { Link } from "react-router-dom"; import Mermaid from "../Mermaid.js"; +import "regenerator-runtime/runtime"; +import "@testing-library/jest-dom"; -test("renders chart", () => { - render( - +test("renders chart", async () => { + render(); + /// not sure why the graph isn't rendering :( + await waitFor(() => + expect(screen.getByText("Syntax error in graph")).toBeInTheDocument() ); - //expect(screen.getByRole('link')).toHaveAttribute('href', 'https://www.test.com'); - // const linkElement = screen.getByText(/TestGoal/i); - // expect(linkElement).toBeInTheDocument(); - expect(true); });