one
Version:
One is a new React Framework that makes Vite serve both native and web.
74 lines (73 loc) • 2.69 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { describe, expect, it, vi } from "vitest";
import { StackToolbar } from "../StackToolbar.native.js";
import { STACK_TOOLBAR_CHILD } from "../StackToolbarImplementation.native.js";
import { exposeStackToolbarConfig } from "../StackToolbar.shared.native.js";
import { appendScreenStackPropsToOptions } from "../StackScreen.native.js";
describe("Stack.Toolbar headless config", function () {
it("marks declaration children for installed implementations", function () {
expect(StackToolbar.Button[STACK_TOOLBAR_CHILD]).toBe("button");
expect(StackToolbar.MenuAction[STACK_TOOLBAR_CHILD]).toBe("menuAction");
});
it("preserves every placement for the headless stack implementation", function () {
var options = appendScreenStackPropsToOptions({
title: "Inbox"
}, {
children: [/* @__PURE__ */_jsx(StackToolbar, {
placement: "left",
children: /* @__PURE__ */_jsx(StackToolbar.Button, {
icon: "sidebar.left"
})
}, "left"), /* @__PURE__ */_jsx(StackToolbar, {
placement: "right",
children: /* @__PURE__ */_jsx(StackToolbar.Button, {
icon: "square.and.arrow.up"
})
}, "right")]
});
expect(exposeStackToolbarConfig(options)).toMatchObject({
title: "Inbox",
toolbar: {
left: {
placement: "left"
},
right: {
placement: "right"
}
}
});
});
it("hands toolbar declarations to an installed implementation", function () {
var _appendPropsToOptions_mock_calls_;
var appendPropsToOptions = vi.fn(function (options2) {
return {
...options2,
headerShown: true
};
});
var implementation = {
appendPropsToOptions,
render: function () {
return null;
}
};
var toolbar = /* @__PURE__ */_jsx(StackToolbar, {
placement: "right",
children: /* @__PURE__ */_jsx(StackToolbar.Button, {
icon: "square.and.arrow.up",
children: "Share"
})
});
var options = appendScreenStackPropsToOptions({
title: "Inbox"
}, {
children: toolbar
}, implementation);
expect(options.headerShown).toBe(true);
expect(appendPropsToOptions).toHaveBeenCalledOnce();
expect((_appendPropsToOptions_mock_calls_ = appendPropsToOptions.mock.calls[0]) === null || _appendPropsToOptions_mock_calls_ === void 0 ? void 0 : _appendPropsToOptions_mock_calls_[1]).toBe(toolbar.props);
expect(exposeStackToolbarConfig(options).toolbar.right).toBe(toolbar.props);
});
});
//# sourceMappingURL=StackToolbar.test.native.js.map