import { render } from "@testing-library/react"; import React from "react"; import { componentDisplayName } from "../utils/componentDisplayName"; import { withSpread } from "./withSpread"; interface ExampleProps { a: number; b: number; } function Example(props: ExampleProps): JSX.Element { return
{JSON.stringify(props)};
}
it("withSpread name", () => {
const Component = withSpread("obj")(Example);
expect(componentDisplayName.get(Component)).toBe("withSpread.obj(Example)");
});
it("withSpread", () => {
const Component = withSpread<"obj", "a">("obj")(Example);
render(
{"a":1,"obj":{"a":1},"b":2}',
);
});