41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
|
|
import { describe, expect, it } from 'vitest'
|
||
|
|
import { UNIVERSAL_ROW_VERSION } from '@sf/contracts'
|
||
|
|
import { DEFAULT_WXR_LIMITS, type WxrLimits } from '../src/limits.js'
|
||
|
|
|
||
|
|
describe('DEFAULT_WXR_LIMITS 值域冻结(设计基线 §7.2 流式解析)', () => {
|
||
|
|
it('十字段默认值与冻结值域一致', () => {
|
||
|
|
expect(DEFAULT_WXR_LIMITS).toStrictEqual({
|
||
|
|
maxWxrBytes: 64 * 1024 * 1024,
|
||
|
|
maxItems: 200_000,
|
||
|
|
maxDepth: 64,
|
||
|
|
maxCdataLength: 1024 * 1024,
|
||
|
|
maxFieldLength: 1024 * 1024,
|
||
|
|
maxTermCount: 50_000,
|
||
|
|
maxMetaPerItem: 200,
|
||
|
|
timeBudgetMs: 120_000,
|
||
|
|
phpMaxDepth: 8,
|
||
|
|
phpMaxElements: 1000,
|
||
|
|
})
|
||
|
|
})
|
||
|
|
|
||
|
|
it('WxrLimits 类型字段齐全:显式构造完整对象通过类型(编译期保证)', () => {
|
||
|
|
const limits: WxrLimits = {
|
||
|
|
maxWxrBytes: 1,
|
||
|
|
maxItems: 1,
|
||
|
|
maxDepth: 1,
|
||
|
|
maxCdataLength: 1,
|
||
|
|
maxFieldLength: 1,
|
||
|
|
maxTermCount: 1,
|
||
|
|
maxMetaPerItem: 1,
|
||
|
|
timeBudgetMs: 1,
|
||
|
|
phpMaxDepth: 1,
|
||
|
|
phpMaxElements: 1,
|
||
|
|
}
|
||
|
|
expect(Object.keys(limits).sort()).toStrictEqual(Object.keys(DEFAULT_WXR_LIMITS).sort())
|
||
|
|
})
|
||
|
|
|
||
|
|
it('跨包接线:@sf/contracts 经根 paths/alias 源码直连可用', () => {
|
||
|
|
expect(UNIVERSAL_ROW_VERSION).toBe(1)
|
||
|
|
})
|
||
|
|
})
|