UNPKG

@crossed/ui

Version:

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

97 lines (96 loc) 4.5 kB
var import_jsx_runtime = require("react/jsx-runtime"); var import_test = require("@crossed/test"); var import_useLogic = require("../useLogic"); var import_Title = require("../Title"); var import_Footer = require("../Footer"); var import_Body = require("../Body"); var import_react = require("react"); describe("useLogic", () => { test("extrait le titre des enfants", () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body") ] }) ); expect(result.current.title).not.toBeNull(); expect(result.current.title.props.children).toBe( "Titre du composant" ); }); test("extrait le footer des enfants", () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Footer.Footer, { children: "Footer du composant" }, "footer") ] }) ); expect(result.current.footer).not.toBeNull(); expect(result.current.footer.props.children).toBe( "Footer du composant" ); }); test("extrait le body des enfants", () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body") ] }) ); expect(result.current.body).not.toBeNull(); expect(result.current.body.props.children).toBe( "Contenu du composant" ); }); test("met \xE0 jour le paddingRight en fonction de la diff\xE9rence entre layoutShared et contentLayoutShared", async () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Footer.Footer, { children: "Footer du composant" }, "footer") ] }) ); result.current.onLayout({ nativeEvent: { layout: { width: 300 } } }); await (0, import_react.act)(() => new Promise((resolve) => setTimeout(resolve, 100))); expect(result.current.paddingRight).toBe(0); }); test("g\xE8re l'affichage du footer lorsque stickyFooter est true", async () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Footer.Footer, { children: "Footer du composant" }, "footer") ], stickyFooter: true }) ); await (0, import_react.act)(() => new Promise((resolve) => setTimeout(resolve, 100))); expect(result.current.showFooter).toBe(true); }); test("n'affiche pas le footer lorsque stickyFooter est false", () => { const { result } = (0, import_test.renderHook)( () => (0, import_useLogic.useLogic)({ children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Title.Title, { children: "Titre du composant" }, "title"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Body.Body, { children: "Contenu du composant" }, "body"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Footer.Footer, { children: "Footer du composant" }, "footer") ], stickyFooter: false }) ); expect(result.current.showFooter).toBe(false); }); }); //# sourceMappingURL=useLogic.spec.js.map