feat: 新增 Taro 模板双端运行与独立 Web 预览
This commit is contained in:
1 parent
f4061a24bd
commit
7e8fc01fba
48 files changed
+11576
-12
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { missingField, visibleFields, slot, offering } from "../src/runtime/content.ts";
|
||||
test("条件字段与空数组校验使用实际显示字段", () => {
|
||||
const fields = [
|
||||
{ key: "type", type: "select", label: "类型", required: true },
|
||||
{
|
||||
key: "choices",
|
||||
type: "checkbox",
|
||||
label: "选项",
|
||||
required: true,
|
||||
visibleWhen: [{ field: "type", operator: "equals", value: "group" }],
|
||||
},
|
||||
];
|
||||
assert.equal(visibleFields(fields, { type: "daily" }).length, 1);
|
||||
assert.equal(missingField(fields, { type: "group", choices: [] }).key, "choices");
|
||||
assert.equal(missingField(fields, { type: "group", choices: ["a"] }), undefined);
|
||||
});
|
||||
test("结构化来源优先,详情使用公开投影", () => {
|
||||
const item = slot(
|
||||
{
|
||||
trustItems: [
|
||||
{ type: "credential", config: {}, content: "old" },
|
||||
{ type: "credential", config: { standards: [] }, content: "edited" },
|
||||
],
|
||||
},
|
||||
"credential",
|
||||
);
|
||||
assert.equal(item.content, "edited");
|
||||
const data = offering({
|
||||
id: "a",
|
||||
summary: "摘要",
|
||||
coverUrl: "cover",
|
||||
priceText: "报价",
|
||||
presentation: {
|
||||
categoryLabel: "套餐",
|
||||
heroImage: "hero",
|
||||
keywords: [],
|
||||
details: { background: "实际餐品说明" },
|
||||
},
|
||||
});
|
||||
assert.equal(data.image, "hero");
|
||||
assert.equal(data.details.background, "实际餐品说明");
|
||||
});
|
||||
Reference in new issue
Block a user