test: OPFSEngine 12项mock测试 + Schema约束5项测试 → 543 passed
CI / test (18.x) (push) Successful in 9m58s
CI / test (20.x) (push) Successful in 9m58s
CI / test (22.x) (push) Successful in 10m18s
CI / test (24.x) (push) Successful in 10m2s

This commit is contained in:
thzxx
2026-07-27 21:34:12 +08:00
parent 2493209611
commit d33f4ab3b0
3 changed files with 184 additions and 2 deletions
+24
View File
@@ -145,6 +145,30 @@ describe('Schema 边缘场景', () => {
});
});
// ---- 约束校验(v0.2.3 ----
describe('约束校验', () => {
it('string 超出 maxLength 抛出错误', () => {
expect(() => checkFieldType('t', 'c', 'string', 'hello', { type: 'string', maxLength: 3 }))
.toThrow('exceeds max length');
});
it('string 未超 maxLength 不报错', () => {
expect(() => checkFieldType('t', 'c', 'string', 'hi', { type: 'string', maxLength: 5 }))
.not.toThrow();
});
it('number 低于 min 抛出错误', () => {
expect(() => checkFieldType('t', 'c', 'number', -5, { type: 'number', min: 0 }))
.toThrow('below minimum');
});
it('number 高于 max 抛出错误', () => {
expect(() => checkFieldType('t', 'c', 'number', 200, { type: 'number', max: 100 }))
.toThrow('above maximum');
});
it('number 在范围内不报错', () => {
expect(() => checkFieldType('t', 'c', 'number', 50, { type: 'number', min: 0, max: 100 }))
.not.toThrow();
});
});
// ---- astColumnToColumnDef ----
describe('astColumnToColumnDef', () => {