Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
simplify spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Feb 14, 2016
1 parent 2b14f03 commit aa03029
Showing 1 changed file with 18 additions and 72 deletions.
90 changes: 18 additions & 72 deletions spec/linter-xmllint-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ describe 'The xmllint provider for Linter', ->
return atom.workspace.open(__dirname + '/fixtures/not-well-formed.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 3
expect(messages[0].range[0][1]).toEqual 8
expect(messages[0].range[1][0]).toEqual 3
expect(messages[0].range[1][1]).toEqual 8
expect(messages[0].range).toEqual [[3, 8], [3, 8]]

it 'finds nothing wrong with valid files', ->
waitsForPromise ->
Expand Down Expand Up @@ -73,118 +70,67 @@ describe 'The xmllint provider for Linter', ->
return atom.workspace.open(__dirname + '/fixtures/invalid/inline-dtd.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 2
expect(messages[0].range[0][0]).toEqual 10
expect(messages[0].range[0][1]).toEqual 8
expect(messages[0].range[1][0]).toEqual 10
expect(messages[0].range[1][1]).toEqual 8
expect(messages[0].range).toEqual [[10, 8], [10, 8]]
expect(messages[0].text).toEqual 'No declaration for element foo (DTD)'
expect(messages[1].range[0][0]).toEqual 14
expect(messages[1].range[0][1]).toEqual 7
expect(messages[1].range[1][0]).toEqual 14
expect(messages[1].range[1][1]).toEqual 7
expect(messages[1].range).toEqual [[14, 7], [14, 7]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/external-dtd.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 3
expect(messages[0].range[0][1]).toEqual 11
expect(messages[0].range[1][0]).toEqual 3
expect(messages[0].range[1][1]).toEqual 11
expect(messages[0].range).toEqual [[3, 11], [3, 11]]
expect(messages[0].text).toEqual 'No declaration for attribute id of element to (DTD)'
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/noNamespaceSchemaLocation.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 9
expect(messages[0].range[0][1]).toEqual 2
expect(messages[0].range[1][0]).toEqual 9
expect(messages[0].range[1][1]).toEqual 51
expect(messages[0].range).toEqual [[9, 2], [9, 51]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/schemaLocation.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 6
expect(messages[0].range[0][1]).toEqual 2
expect(messages[0].range[1][0]).toEqual 6
expect(messages[0].range[1][1]).toEqual 21
expect(messages[0].range).toEqual [[6, 2], [6, 21]]
expect(messages[0].text).toEqual "Element '{http://www.w3schools.com}to', attribute 'id': The attribute 'id' is not allowed. (../note.xsd)"
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/not-well-formed.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 7
expect(messages[0].range[0][1]).toEqual 16
expect(messages[0].range[1][0]).toEqual 7
expect(messages[0].range[1][1]).toEqual 16
expect(messages[0].range).toEqual [[7, 16], [7, 16]]
expect(messages[0].text).toEqual 'Opening and ending tag mismatch: to line 8 and two'
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/xsd-error.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 10
expect(messages[0].range[0][1]).toEqual 2
expect(messages[0].range[1][0]).toEqual 10
expect(messages[0].range[1][1]).toEqual 50
expect(messages[0].range).toEqual [[10, 2], [10, 50]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/dtd-error.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 2
expect(messages[0].range[0][0]).toEqual 11
expect(messages[0].range[0][1]).toEqual 11
expect(messages[0].range[1][0]).toEqual 11
expect(messages[0].range[1][1]).toEqual 11
expect(messages[1].range[0][0]).toEqual 12
expect(messages[1].range[0][1]).toEqual 7
expect(messages[1].range[1][0]).toEqual 12
expect(messages[1].range[1][1]).toEqual 7
expect(messages[0].range).toEqual [[11, 11], [11, 11]]
expect(messages[1].range).toEqual [[12, 7], [12, 7]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/xml-model-error.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 1
expect(messages[0].range[0][0]).toEqual 3
expect(messages[0].range[0][1]).toEqual 2
expect(messages[0].range[1][0]).toEqual 3
expect(messages[0].range[1][1]).toEqual 21
expect(messages[0].range).toEqual [[3, 2], [3, 21]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/relax-errors.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 2
expect(messages[0].range[0][0]).toEqual 8
expect(messages[0].range[0][1]).toEqual 2
expect(messages[0].range[1][0]).toEqual 8
expect(messages[0].range[1][1]).toEqual 11
expect(messages[0].range).toEqual [[8, 2], [8, 11]]
expect(messages[0].text).toEqual 'Did not expect element footer there (../note.rng)'
expect(messages[1].range[0][0]).toEqual 7
expect(messages[1].range[0][1]).toEqual 2
expect(messages[1].range[1][0]).toEqual 7
expect(messages[1].range[1][1]).toEqual 44
expect(messages[1].range).toEqual [[7, 2], [7, 44]]
expect(messages[1].text).toEqual 'Did not expect element body there (../note2.rng)'
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/multiple-errors.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 3
expect(messages[0].range[0][0]).toEqual 11
expect(messages[0].range[0][1]).toEqual 11
expect(messages[0].range[1][0]).toEqual 11
expect(messages[0].range[1][1]).toEqual 11
expect(messages[1].range[0][0]).toEqual 12
expect(messages[1].range[0][1]).toEqual 7
expect(messages[1].range[1][0]).toEqual 12
expect(messages[1].range[1][1]).toEqual 7
expect(messages[2].range[0][0]).toEqual 10
expect(messages[2].range[0][1]).toEqual 2
expect(messages[2].range[1][0]).toEqual 10
expect(messages[2].range[1][1]).toEqual 54
expect(messages[0].range).toEqual [[11, 11], [11, 11]]
expect(messages[1].range).toEqual [[12, 7], [12, 7]]
expect(messages[2].range).toEqual [[10, 2], [10, 54]]
waitsForPromise ->
return atom.workspace.open(__dirname + '/fixtures/invalid/schematron-errors.xml').then (editor) ->
return lint(editor).then (messages) ->
expect(messages.length).toEqual 2
expect(messages[0].range[0][0]).toEqual 2
expect(messages[0].range[0][1]).toEqual 0
expect(messages[0].range[1][0]).toEqual 2
expect(messages[0].range[1][1]).toEqual 6
expect(messages[0].range).toEqual [[2, 0], [2, 6]]
expect(messages[0].text).toEqual '/note: Note must have a "from" (../schematron.xml)'
expect(messages[1].range[0][0]).toEqual 2
expect(messages[1].range[0][1]).toEqual 0
expect(messages[1].range[1][0]).toEqual 2
expect(messages[1].range[1][1]).toEqual 6
expect(messages[1].range).toEqual [[2, 0], [2, 6]]

0 comments on commit aa03029

Please sign in to comment.