From aa03029d9aeabe90e0711f74c152cd5706244332 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Sat, 13 Feb 2016 16:48:15 -0800 Subject: [PATCH] simplify spec --- spec/linter-xmllint-spec.coffee | 90 +++++++-------------------------- 1 file changed, 18 insertions(+), 72 deletions(-) diff --git a/spec/linter-xmllint-spec.coffee b/spec/linter-xmllint-spec.coffee index 836d244..32bb63c 100644 --- a/spec/linter-xmllint-spec.coffee +++ b/spec/linter-xmllint-spec.coffee @@ -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 -> @@ -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]]