5b2: make the pipe escape terminate, cap the value a document fault echoes
CI / gate (push) Successful in 9s

This commit is contained in:
2026-09-03 18:45:17 +02:00
parent 240ea8eb64
commit 2ff03a1396
5 changed files with 11 additions and 7 deletions
+2
View File
@@ -19,6 +19,8 @@ test('names the check anything that is not a doc node failed', () => {
assert.equal(fault(undefined), 'an ADF document is an object: found undefined')
assert.equal(fault([]), 'an ADF document is an object: found an array')
assert.equal(fault('doc'), 'an ADF document is an object: found "doc"')
assert.equal(fault('x'.repeat(200000)), `an ADF document is an object: found "${'x'.repeat(40)}…"`)
assert.equal(fault(function named(first: number, second: number) { return first + second }), 'an ADF document is an object: found a function')
assert.equal(fault({ fields: { description: { type: 'doc', version: 1 } } }), 'an ADF document holds content, type and version alone: found the key fields')
assert.equal(fault({ extra: 1, type: 'doc', version: 1 }), 'an ADF document holds content, type and version alone: found the key extra')
assert.equal(fault({ version: 1 }), 'an ADF document holds type "doc": found no type field')
+2 -1
View File
@@ -90,7 +90,8 @@ function isRecord(value: unknown): value is Record<string, unknown> {
}
function describe(value: unknown): string {
if (typeof value === 'string') return JSON.stringify(value)
if (typeof value === 'string') return JSON.stringify(value.length > 40 ? `${value.slice(0, 40)}…` : value)
if (typeof value === 'function') return 'a function'
if (typeof value === 'object' && value !== null) return Array.isArray(value) ? 'an array' : 'an object'
return String(value)
}