Skip to content

Commit

Permalink
test: Add now-successful tests for anchors on tagged collections
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Mar 27, 2021
1 parent ea7aba7 commit f12ff89
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/doc/anchors.js
Expand Up @@ -38,6 +38,23 @@ test('circular reference', () => {
expect(String(doc)).toBe(src)
})

describe('anchor on tagged collection', () => {
test('!!set', () => {
const res = YAML.parse('- &a !!set { 1, 2 }\n- *a\n')
expect(Array.from(res[0])).toMatchObject([1, 2])
expect(res[1]).toBe(res[0])
})

test('!!omap', () => {
const res = YAML.parse('- &a !!omap [ 1: 1, 2: 2 ]\n- *a\n')
expect(Array.from(res[0])).toMatchObject([
[1, 1],
[2, 2]
])
expect(res[1]).toBe(res[0])
})
})

describe('create', () => {
test('node.anchor', () => {
const doc = YAML.parseDocument('[{ a: A }, { b: B }]')
Expand Down

0 comments on commit f12ff89

Please sign in to comment.