@crossed/primitive
Version:
A universal & performant styling library for React Native, Next.js & React
90 lines (89 loc) • 4.72 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_jsx_runtime = require("react/jsx-runtime");
var import_jest_dom = require("@testing-library/jest-dom");
var import_react = require("react");
var import__ = require("../index");
var import_List = require("../List");
var import_ListItem = require("../ListItem");
var import_ListSubTitle = require("../ListSubTitle");
var import_ListTitle = require("../ListTitle");
var import_ListLabel = require("../ListLabel");
var import_ListDivider = require("../ListDivider");
var allExport = __toESM(require("../index"));
const createListMainMocked = import_List.createListMain;
const createListItemMocked = import_ListItem.createListItem;
const createListSubTitleMocked = import_ListSubTitle.createListSubTitle;
const createListTitleMocked = import_ListTitle.createListTitle;
const createListLabelMocked = import_ListLabel.createListLabel;
const createListDividerMocked = import_ListDivider.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 = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const Item = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const Label = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const SubTitle = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const Title = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const Divider = (0, import_react.forwardRef)((p, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { ...p, ref }));
const List = (0, import__.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