-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95f4476
commit 85d4828
Showing
6 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from "react"; | ||
import { fireEvent, render, screen } from "@testing-library/react"; | ||
import App from "../App"; | ||
|
||
describe("App", () => { | ||
beforeEach(() => { | ||
render(<App />); | ||
}); | ||
|
||
it("renders Output heading", () => { | ||
expect(screen.getByText("Output").nodeName).toEqual("H2"); | ||
}); | ||
|
||
it("renders ErrorBoundary fallback element when draw function throws error", () => { | ||
jest.mock("../../../src/index", () => ({ | ||
draw: jest.fn(() => { | ||
throw new Error(); | ||
}), | ||
})); | ||
const input = screen.getByLabelText("Enter memory model JSON here"); | ||
// In order to get to draw function, input has to be valid json otherwise JSON.parse fails | ||
fireEvent.change(input, { target: { value: "[{}]" } }); | ||
const button = screen.getByTestId("input-submit-button"); | ||
fireEvent.click(button); | ||
|
||
const errorBoundary = screen.getByTestId("svg-display-error-boundary"); | ||
expect(errorBoundary.textContent).toEqual("Something went wrong"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters