import { render } from "@testing-library/react"; import React from "react"; import { componentDisplayName } from "../utils/componentDisplayName"; import { withPick } from "./withPick"; interface ExampleProps { a?: number; b?: number; c?: number; } function Example(props: ExampleProps): JSX.Element { return
{JSON.stringify(props)}
; } it("withPick name", () => { const Component = withPick(["b", "a"])(Example); expect(componentDisplayName.get(Component)).toBe("withPick.b.a(Example)"); }); it("withPick", () => { const Component = withPick(["b"])(Example); render(); expect(document.body.children[0].innerHTML).toBe('
{"b":1}
'); });