UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

100 lines (98 loc) 4.56 kB
"use strict"; 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_react = __toESM(require("react"), 1); var import_vitest = require("vitest"); var import_StackToolbar = require("../StackToolbar.native.js"); var import_StackToolbarImplementation = require("../StackToolbarImplementation.native.js"); var import_StackToolbar2 = require("../StackToolbar.shared"); var import_StackScreen = require("../StackScreen.native.js"); (0, import_vitest.describe)("Stack.Toolbar headless config", function () { (0, import_vitest.it)("marks declaration children for installed implementations", function () { (0, import_vitest.expect)(import_StackToolbar.StackToolbar.Button[import_StackToolbarImplementation.STACK_TOOLBAR_CHILD]).toBe("button"); (0, import_vitest.expect)(import_StackToolbar.StackToolbar.MenuAction[import_StackToolbarImplementation.STACK_TOOLBAR_CHILD]).toBe("menuAction"); }); (0, import_vitest.it)("preserves every placement for the headless stack implementation", function () { var options = (0, import_StackScreen.appendScreenStackPropsToOptions)({ title: "Inbox" }, { children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar, { placement: "left", children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar.Button, { icon: "sidebar.left" }) }, "left"), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar, { placement: "right", children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar.Button, { icon: "square.and.arrow.up" }) }, "right")] }); (0, import_vitest.expect)((0, import_StackToolbar2.exposeStackToolbarConfig)(options)).toMatchObject({ title: "Inbox", toolbar: { left: { placement: "left" }, right: { placement: "right" } } }); }); (0, import_vitest.it)("hands toolbar declarations to an installed implementation", function () { var _appendPropsToOptions_mock_calls_; var appendPropsToOptions = import_vitest.vi.fn(function (options2) { return { ...options2, headerShown: true }; }); var implementation = { appendPropsToOptions, render: function () { return null; } }; var toolbar = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar, { placement: "right", children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StackToolbar.StackToolbar.Button, { icon: "square.and.arrow.up", children: "Share" }) }); var options = (0, import_StackScreen.appendScreenStackPropsToOptions)({ title: "Inbox" }, { children: toolbar }, implementation); (0, import_vitest.expect)(options.headerShown).toBe(true); (0, import_vitest.expect)(appendPropsToOptions).toHaveBeenCalledOnce(); (0, import_vitest.expect)((_appendPropsToOptions_mock_calls_ = appendPropsToOptions.mock.calls[0]) === null || _appendPropsToOptions_mock_calls_ === void 0 ? void 0 : _appendPropsToOptions_mock_calls_[1]).toBe(toolbar.props); (0, import_vitest.expect)((0, import_StackToolbar2.exposeStackToolbarConfig)(options).toolbar.right).toBe(toolbar.props); }); }); //# sourceMappingURL=StackToolbar.test.native.js.map