diff --git a/tests/doc/parse.js b/tests/doc/parse.js index f192e456..0154e9b2 100644 --- a/tests/doc/parse.js +++ b/tests/doc/parse.js @@ -79,17 +79,17 @@ describe('custom string on node', () => { test('tiled null', () => { YAML.scalarOptions.null.nullStr = '~' const doc = YAML.parse('a: null') - const str = YAML.stringify(doc, {simpleKeys: true}) + const str = YAML.stringify(doc, { simpleKeys: true }) expect(str).toBe('a: ~\n') - expect(YAML.parse(str)).toEqual({a: null}) + expect(YAML.parse(str)).toEqual({ a: null }) }) test('empty string null', () => { YAML.scalarOptions.null.nullStr = '' const doc = YAML.parse('a: null') - const str = YAML.stringify(doc, {simpleKeys: true}) + const str = YAML.stringify(doc, { simpleKeys: true }) expect(str).toBe('a: \n') - expect(YAML.parse(str)).toEqual({a: null}) + expect(YAML.parse(str)).toEqual({ a: null }) }) }) @@ -232,7 +232,7 @@ test('eemeli/yaml#3', () => { const src = '{ ? : 123 }' const doc = YAML.parseDocument(src) expect(doc.errors).toHaveLength(0) - expect(doc.contents.items[0].key).toBeNull() + expect(doc.contents.items[0].key.value).toBeNull() expect(doc.contents.items[0].value.value).toBe(123) }) @@ -370,13 +370,13 @@ describe('eemeli/yaml#l19', () => { test('map', () => { const src = 'a:\n # 123' const doc = YAML.parseDocument(src) - expect(String(doc)).toBe('? a\n\n# 123\n') + expect(String(doc)).toBe('a: # 123\n') }) test('seq', () => { const src = '- a: # 123' const doc = YAML.parseDocument(src) - expect(String(doc)).toBe('- ? a # 123\n') + expect(String(doc)).toBe('- a: # 123\n') }) }) @@ -414,7 +414,10 @@ test('eemeli/yaml#38', () => { expect(YAML.parse(src)).toEqual({ content: { arrayOfArray: [ - [{ first: 'John', last: 'Black' }, { first: 'Brian', last: 'Green' }], + [ + { first: 'John', last: 'Black' }, + { first: 'Brian', last: 'Green' } + ], [{ first: 'Mark', last: 'Orange' }], [{ first: 'Adam', last: 'Grey' }] ] @@ -437,17 +440,14 @@ test('comment between key & : in flow collection (eemeli/yaml#149)', () => { const src2 = '{a\n#c\n:1}' expect(() => YAML.parse(src2)).toThrow( - 'Indicator : missing in flow map entry' + 'Missing , between flow collection items' ) }) test('empty node should respect setOrigRanges()', () => { - const cst = YAML.parseCST('\r\na: # 123\r\n') - expect(cst).toHaveLength(1) - expect(cst.setOrigRanges()).toBe(true) - const doc = new YAML.Document(undefined, { keepCstNodes: true }).parse(cst[0]) - const empty = doc.contents.items[0].value.cstNode - expect(empty.range).toEqual({ start: 3, end: 3, origStart: 4, origEnd: 4 }) + const doc = YAML.parseDocument('\r\na: # 123\r\n') + const empty = doc.contents.items[0].value + expect(empty.range).toEqual([12, 12]) }) test('parse an empty string as null', () => {