-
Notifications
You must be signed in to change notification settings - Fork 526
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
e5f69e4
commit 960e266
Showing
2 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** @jest-environment jsdom */ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
import { screen } from "@testing-library/react"; | ||
import { act } from "react-dom/test-utils"; | ||
|
||
import { createSyncRoot } from "@foxglove/studio-base/panels/createSyncRoot"; | ||
|
||
describe("createSyncRoot", () => { | ||
it("should mount the component", async () => { | ||
const textTest = "Mount Component Test"; | ||
const TestComponent = () => <div>{textTest}</div>; | ||
|
||
const container = document.createElement("div"); | ||
document.body.appendChild(container); | ||
|
||
act(() => { | ||
createSyncRoot(<TestComponent />, container); | ||
}); | ||
|
||
expect(await screen.findByText(textTest)).toBeDefined(); | ||
}); | ||
|
||
it("should unmount the component", async () => { | ||
const textTest = "Unmount Component Test"; | ||
const TestComponent = () => <div>{textTest}</div>; | ||
|
||
const container = document.createElement("div"); | ||
document.body.appendChild(container); | ||
|
||
act(() => { | ||
const unmountCb = createSyncRoot(<TestComponent />, container); | ||
unmountCb(); | ||
}); | ||
|
||
expect(JSON.stringify(await screen.findByText(textTest))).toBe("{}"); | ||
}); | ||
}); |
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