@crossed/primitive
Version:
A universal & performant styling library for React Native, Next.js & React
67 lines (66 loc) • 3.14 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import "@testing-library/jest-dom";
import { forwardRef } from "react";
import { createList } from "../index";
import { createListMain } from "../List";
import { createListItem } from "../ListItem";
import { createListSubTitle } from "../ListSubTitle";
import { createListTitle } from "../ListTitle";
import { createListLabel } from "../ListLabel";
import { createListDivider } from "../ListDivider";
import * as allExport from "../index";
const createListMainMocked = createListMain;
const createListItemMocked = createListItem;
const createListSubTitleMocked = createListSubTitle;
const createListTitleMocked = createListTitle;
const createListLabelMocked = createListLabel;
const createListDividerMocked = createListDivider;
jest.mock("../List");
jest.mock("../ListItem");
jest.mock("../ListSubTitle");
jest.mock("../ListTitle");
jest.mock("../ListLabel");
jest.mock("../ListDivider");
describe("createList", () => {
beforeEach(() => {
createListMainMocked.mockImplementation((e) => e);
createListItemMocked.mockImplementation((e) => e);
createListSubTitleMocked.mockImplementation((e) => e);
createListTitleMocked.mockImplementation((e) => e);
createListLabelMocked.mockImplementation((e) => e);
createListDividerMocked.mockImplementation((e) => e);
});
afterEach(() => {
createListMainMocked.mockReset();
createListItemMocked.mockReset();
createListSubTitleMocked.mockReset();
createListTitleMocked.mockReset();
createListLabelMocked.mockReset();
createListDividerMocked.mockReset();
});
test("check exports", () => {
expect(Object.keys(allExport)).toEqual(["createList"]);
});
test("init", async () => {
const Root = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const Item = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const Label = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const SubTitle = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const Title = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const Divider = forwardRef((p, ref) => /* @__PURE__ */ jsx("p", { ...p, ref }));
const List = createList({ Root, Item, Label, SubTitle, Title, Divider });
expect(createListMainMocked).toHaveBeenCalledWith(Root);
expect(createListItemMocked).toHaveBeenCalledWith(Item);
expect(createListSubTitleMocked).toHaveBeenCalledWith(SubTitle);
expect(createListTitleMocked).toHaveBeenCalledWith(Title);
expect(createListLabelMocked).toHaveBeenCalledWith(Label);
expect(createListDividerMocked).toHaveBeenCalledWith(Divider);
expect(List).toHaveProperty("displayName", "List");
expect(List.Item).toHaveProperty("displayName", "List.Item");
expect(List.Label).toHaveProperty("displayName", "List.Label");
expect(List.SubTitle).toHaveProperty("displayName", "List.SubTitle");
expect(List.Title).toHaveProperty("displayName", "List.Title");
expect(List.Divider).toHaveProperty("displayName", "List.Divider");
});
});
//# sourceMappingURL=createList.spec.js.map