mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
29 lines
726 B
TypeScript
29 lines
726 B
TypeScript
import React from "react";
|
|
import {renderToStaticMarkup} from "react-dom/server";
|
|
|
|
import {useIsMounted} from "../src";
|
|
|
|
function Example() {
|
|
const [, isMounted] = useIsMounted({rerender: true});
|
|
|
|
return <p>{isMounted ? "mounted" : "not mounted"}</p>;
|
|
}
|
|
|
|
describe("useIsMounted", () => {
|
|
it("should export a function", () => {
|
|
expect(useIsMounted).toBeInstanceOf(Function);
|
|
});
|
|
|
|
it("should return false before mount (default)", () => {
|
|
const text = renderToStaticMarkup(<Example />);
|
|
|
|
expect(text).toBe("<p>not mounted</p>");
|
|
});
|
|
|
|
it("should return false before mount (beforePaint)", () => {
|
|
const text = renderToStaticMarkup(<Example />);
|
|
|
|
expect(text).toBe("<p>not mounted</p>");
|
|
});
|
|
});
|