Skip to content

Commit 2b258fc

Browse files
authored
fix: fix scalar alone line parsing (#18)
1 parent 1c16a6a commit 2b258fc

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/aria/yaml.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class Parser {
243243
return this.parseMap(line.indent)
244244
}
245245
// Single scalar
246+
this.pos++
246247
return this.parseScalarValue(line.content, line.offset, line)
247248
}
248249

test/aria.test.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,29 @@ describe('parseAriaTemplate', () => {
24352435
`)
24362436
})
24372437

2438+
test('nested scalar text child', () => {
2439+
const t = parseAriaTemplate(`
2440+
- button:
2441+
Submit
2442+
`)
2443+
expect(t).toMatchInlineSnapshot(`
2444+
{
2445+
"children": [
2446+
{
2447+
"kind": "text",
2448+
"text": {
2449+
"normalized": "Submit",
2450+
"raw": "Submit",
2451+
},
2452+
},
2453+
],
2454+
"kind": "role",
2455+
"name": undefined,
2456+
"role": "button",
2457+
}
2458+
`)
2459+
})
2460+
24382461
test('regex text node', () => {
24392462
const t = parseAriaTemplate('- text: /hello \\d+/')
24402463
expect(t).toMatchInlineSnapshot(`
@@ -2495,10 +2518,10 @@ describe('parseAriaTemplate', () => {
24952518
`[Error: Aria snapshot must be a YAML sequence, elements starting with " -"]`
24962519
)
24972520
expect(() => parseAriaTemplate(`hello`)).toThrowErrorMatchingInlineSnapshot(
2498-
`[Error: Unexpected scalar at node end]`
2521+
`[Error: Aria snapshot must be a YAML sequence, elements starting with " -"]`
24992522
)
25002523
expect(() => parseAriaTemplate(`1234`)).toThrowErrorMatchingInlineSnapshot(
2501-
`[Error: Unexpected scalar at node end]`
2524+
`[Error: Aria snapshot must be a YAML sequence, elements starting with " -"]`
25022525
)
25032526
})
25042527

0 commit comments

Comments
 (0)