3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

5b1: name the line and the offset in the input a parse refusal sits at

This commit is contained in:
2026-09-03 14:37:39 +02:00
parent 607699c0ea
commit 47ca41b558
10 changed files with 146 additions and 66 deletions
+6 -1
View File
@@ -25,12 +25,17 @@ function path(result: Result<string>): readonly (number | string)[] {
return result.ok ? ['emitted'] : result.error.path
}
test('names the node a refusal came from', () => {
function position(result: Result<string>): unknown {
return result.ok ? 'emitted' : result.error.position
}
test('names the node a refusal came from, and no source the emitter never read', () => {
const unspellable: AdfNode = { text: 'x', type: 'paragraph' }
const list: AdfNode = { content: [{ content: [paragraph({ text: 'x', type: 'text' })], type: 'listItem' }, { content: [unspellable], type: 'listItem' }], type: 'bulletList' }
assert.deepEqual(path(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }), list))), ['content', 1, 'content', 1, 'content', 0])
assert.deepEqual(path(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }, { type: 'text' })))), ['content', 0, 'content', 1])
assert.deepEqual(path(adfToMarkdown({ type: 'doc', version: 2 })), [])
assert.equal(position(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }), list))), undefined)
})
test('refuses a value that is not an ADF document', () => {