one
Version:
One is a new React Framework that makes Vite serve both native and web.
66 lines • 3.01 kB
JavaScript
var import_vitest = require("vitest");
var import_StackToolbar = require("../StackToolbar.cjs");
var import_StackToolbarImplementation = require("../StackToolbarImplementation.cjs");
var import_StackToolbar2 = require("../StackToolbar.shared");
var import_StackScreen = require("../StackScreen.cjs");
var import_jsx_runtime = require("react/jsx-runtime");
(0, import_vitest.describe)("Stack.Toolbar headless config", () => {
(0, import_vitest.it)("marks declaration children for installed implementations", () => {
(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", () => {
const 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", () => {
const appendPropsToOptions = import_vitest.vi.fn(options2 => ({
...options2,
headerShown: true
}));
const implementation = {
appendPropsToOptions,
render: () => null
};
const 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"
})
});
const 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[0]?.[1]).toBe(toolbar.props);
(0, import_vitest.expect)((0, import_StackToolbar2.exposeStackToolbarConfig)(options).toolbar.right).toBe(toolbar.props);
});
});