From 6715c97599e1134b780d4517de7d2494dd0693d2 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 23 Sep 2026 22:51:03 +0200 Subject: [PATCH] 32 - the deeper helpers read the one limit, and the code directive's refusal is tested --- src/adf/document.test.ts | 3 +-- src/markdown/emit/adf-to-markdown.test.ts | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/adf/document.test.ts b/src/adf/document.test.ts index c6a1b93..20e3b37 100644 --- a/src/adf/document.test.ts +++ b/src/adf/document.test.ts @@ -61,8 +61,7 @@ test('rejects a node whose shape ProseMirror JSON cannot hold', () => { }) test('names the attribute nesting past the levels the parser reads one at, and still calls the value a document', () => { - const deeper = (key: string, type: string, levels: number = largestNesting): string => - `the ${key} attribute of ${type} nests deeper than the ${levels} levels an attribute carries` + const deeper = (key: string, type: string): string => `the ${key} attribute of ${type} nests deeper than the ${largestNesting} levels an attribute carries` assert.equal(fault(withAttribute(nested(largestNesting))), 'accepted') assert.equal(fault(withAttribute(nested(largestNesting + 1))), deeper('a', 'paragraph')) assert.equal(faultCode(withAttribute(nested(largestNesting + 1))), 'unsupported-nesting-depth') diff --git a/src/markdown/emit/adf-to-markdown.test.ts b/src/markdown/emit/adf-to-markdown.test.ts index ec45af7..daf574f 100644 --- a/src/markdown/emit/adf-to-markdown.test.ts +++ b/src/markdown/emit/adf-to-markdown.test.ts @@ -353,8 +353,8 @@ test('refuses marks and attributes nested deeper than the emitter carries', () = assert.equal(code(adfToMarkdown(document(paragraph({ marks, text: 'x', type: 'text' })))), 'unsupported-nesting-depth') let attrs: AdfMark['attrs'] = { depth: 'x' } for (let depth = 0; depth < 600; depth += 1) attrs = { depth: attrs } - const deeper = (key: string, type: string, levels: number = largestNesting): string => - `unsupported-nesting-depth: the ${key} attribute of ${type} nests deeper than the ${levels} levels an attribute carries` + const deeper = (key: string, type: string): string => + `unsupported-nesting-depth: the ${key} attribute of ${type} nests deeper than the ${largestNesting} levels an attribute carries` const nested = (levels: number): JsonValue => { let value: JsonValue = 1 for (let level = 0; level < levels; level += 1) value = [value] @@ -385,6 +385,8 @@ test('refuses marks and attributes nested deeper than the emitter carries', () = roundTrips(paragraph(card(largestNesting))) assert.equal(markdown(adfToMarkdown(document(marked(largestNesting - 2)))), deeper('marks', 'panel')) assert.deepEqual(path(adfToMarkdown(document(marked(largestNesting - 2)))), ['content', 0]) + const markedCode: AdfNode = { content: [{ text: 'x', type: 'text' }], marks: [{ attrs: { deep: nested(largestNesting - 2) }, type: 'em' }], type: 'codeBlock' } + assert.equal(markdown(adfToMarkdown(document(markedCode))), deeper('marks', 'codeBlock')) roundTrips(marked(largestNesting - 3)) })