Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Dec 15, 2020
1 parent 94e0e79 commit b1fdaa0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/doc/parse.js
Expand Up @@ -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 })
})
})

Expand Down Expand Up @@ -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)
})

Expand Down Expand Up @@ -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')
})
})

Expand Down Expand Up @@ -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' }]
]
Expand All @@ -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', () => {
Expand Down

0 comments on commit b1fdaa0

Please sign in to comment.