mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 23:25:43 +01:00
Answer stability round 1: 0 🔴, 2 🟡 (0 misread); import OutermostContent in the test and drop the two tests no bug fails on alone; the two surviving mutants sit past the portable flavour and the emitter's refusals, and commonmark/ stays out of the root's ban
This commit is contained in:
@@ -3,10 +3,10 @@ import test from 'node:test'
|
|||||||
|
|
||||||
import type { AdfNode } from '../adf/document.ts'
|
import type { AdfNode } from '../adf/document.ts'
|
||||||
import type { Result } from '../result.ts'
|
import type { Result } from '../result.ts'
|
||||||
import type { InlineContent } from './inline-content.ts'
|
import type { InlineContent, OutermostContent } from './inline-content.ts'
|
||||||
import { parseInlineContent } from './inline-content.ts'
|
import { parseInlineContent } from './inline-content.ts'
|
||||||
|
|
||||||
function read(source: string): Result<InlineContent & { openingSpellableLink: boolean }> {
|
function read(source: string): Result<OutermostContent> {
|
||||||
return parseInlineContent(source, new Map(), [], 'paragraph', 'lossless')
|
return parseInlineContent(source, new Map(), [], 'paragraph', 'lossless')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ function nodes(result: Result<InlineContent>): AdfNode[] | string {
|
|||||||
return result.ok ? result.value.nodes : result.error.code
|
return result.ok ? result.value.nodes : result.error.code
|
||||||
}
|
}
|
||||||
|
|
||||||
test('reports a directive link opening the line that CommonMark could spell', () => {
|
test('reports a directive link that CommonMark could spell opening the line', () => {
|
||||||
const opening = read('!adf:link[a]{href="/u"}')
|
const opening = read('!adf:link[a]{href="/u"}')
|
||||||
assert.equal(opening.ok && opening.value.openingSpellableLink, true)
|
assert.equal(opening.ok && opening.value.openingSpellableLink, true)
|
||||||
assert.deepEqual(nodes(opening), [{ marks: [{ attrs: { href: '/u' }, type: 'link' }], text: 'a', type: 'text' }])
|
assert.deepEqual(nodes(opening), [{ marks: [{ attrs: { href: '/u' }, type: 'link' }], text: 'a', type: 'text' }])
|
||||||
@@ -24,12 +24,3 @@ test('reports no spellable opening link where the line opens with text', () => {
|
|||||||
const text = read('See a')
|
const text = read('See a')
|
||||||
assert.equal(text.ok && text.value.openingSpellableLink, false)
|
assert.equal(text.ok && text.value.openingSpellableLink, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('reports the opening link whose CommonMark spelling would open a link definition, leaving the writer to answer', () => {
|
|
||||||
const definition = read('!adf:link[`]: a`]{href="/u"}')
|
|
||||||
assert.equal(definition.ok && definition.value.openingSpellableLink, true)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('still refuses a spellable directive link past the opening of the line', () => {
|
|
||||||
assert.equal(nodes(read('See !adf:link[a]{href="/u"}.')), 'unsupported-node-shape')
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user