test: OPFSEngine 12项mock测试 + Schema约束5项测试 → 543 passed
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user