UNPKG

@crossed/primitive

Version:

A universal & performant styling library for React Native, Next.js & React

29 lines (28 loc) 950 B
import { jsx } from "react/jsx-runtime"; import "@testing-library/jest-dom"; import { render, screen } from "@crossed/test"; import { forwardRef } from "react"; import { createButtonText } from "../ButtonText"; import { useContext } from "../context"; const Comp = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref })); const NewComp = createButtonText(Comp); jest.mock("../context"); const useContextMocked = useContext; describe("createButtonText", () => { beforeEach(() => { useContextMocked.mockImplementation(() => ({ id: "id" })); }); afterEach(() => { useContextMocked.mockReset(); }); test("init", async () => { const child = "Pass child"; render(/* @__PURE__ */ jsx(NewComp, { children: child })); expect(useContextMocked).toHaveBeenCalled(); const text = await screen.getByText(child); expect(text).toHaveAttribute("id", "id"); }); }); //# sourceMappingURL=ButtonText.spec.js.map