@crossed/primitive
Version:
A universal & performant styling library for React Native, Next.js & React
30 lines (29 loc) • 961 B
JavaScript
import { jsx } from "react/jsx-runtime";
import "@testing-library/jest-dom";
import { render, screen } from "@crossed/test";
import { LabelInput } from "../LabelInput";
import { useContext } from "../context";
jest.mock("../context");
jest.mock("@crossed/core/src/composeRefs");
const useContextMocked = useContext;
describe("createLabelMain", () => {
beforeEach(() => {
useContextMocked.mockImplementation(() => ({
id: "id",
inputRef: { current: void 0 }
}));
});
afterEach(() => {
useContextMocked.mockReset();
});
test("init", async () => {
render(
/* @__PURE__ */ jsx(LabelInput, { children: /* @__PURE__ */ jsx("input", { "data-testid": "input" }) })
);
expect(useContextMocked).toBeCalled();
const el = await screen.getByTestId("input");
expect(el).toHaveAttribute("id", "id");
expect(el).toHaveAttribute("aria-labelledby", "label-id");
});
});
//# sourceMappingURL=LabelInput.spec.js.map