mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
- 实现配置模式解析器,支持对象、数组和标量类型的递归验证 - 添加 YAML 解析和注释提取功能,支持嵌套对象和数组结构 - 实现配置验证诊断,提供详细的错误和警告信息 - 添加表单更新应用功能,支持标量值和数组的批量编辑 - 实现配置示例生成功能,包含描述信息作为 YAML 注释 - 添加数值约束验证,包括最小值、最大值、倍数和长度限制 - 实现枚举值和模式匹配验证,确保数据符合预定义规则 - 添加常量值比较功能,支持对象和数组类型的深度比较
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const test = require("node:test");
|
||
const assert = require("node:assert/strict");
|
||
const {buildContainsHintLines, describeContainsSchema} = require("../src/containsSummary");
|
||
const {createLocalizer} = require("../src/localization");
|
||
|
||
test("describeContainsSchema should reuse localized Chinese hint strings", () => {
|
||
const localizer = createLocalizer("zh-cn");
|
||
|
||
const summary = describeContainsSchema(
|
||
{
|
||
type: "string",
|
||
constValue: "\"potion\"",
|
||
constDisplayValue: "\"potion\"",
|
||
refTable: "item"
|
||
},
|
||
localizer);
|
||
|
||
assert.equal(summary, "string, 固定值:\"potion\", 引用表:item");
|
||
});
|
||
|
||
test("describeContainsSchema should fall back to localized item label", () => {
|
||
const localizer = createLocalizer("en");
|
||
|
||
const summary = describeContainsSchema({}, localizer);
|
||
|
||
assert.equal(summary, "Item");
|
||
});
|
||
|
||
test("buildContainsHintLines should include default minContains when schema omits it", () => {
|
||
const localizer = createLocalizer("en");
|
||
|
||
const lines = buildContainsHintLines(
|
||
{
|
||
contains: {
|
||
type: "integer",
|
||
constValue: "5",
|
||
constDisplayValue: "5"
|
||
}
|
||
},
|
||
localizer);
|
||
|
||
assert.deepEqual(lines, [
|
||
"Contains: integer, Const: 5",
|
||
"Min contains: 1"
|
||
]);
|
||
});
|