|
1 | 1 | let problemMatcher = require('../.github/problem-matcher.json'); |
2 | 2 | problemMatcher = problemMatcher.problemMatcher[0]; |
3 | 3 |
|
4 | | -const matchResults = function(string, regexp){ |
| 4 | +const matchResults = function(string, regexp) { |
5 | 5 | return string.map(line => regexp.exec(line)); |
6 | 6 | }; |
7 | 7 |
|
8 | | -describe("problemMatcher", () => { |
9 | | - it("has the correct owner", () => { |
10 | | - expect(problemMatcher.owner).toEqual("htmllint"); |
| 8 | +describe('problemMatcher', () => { |
| 9 | + it('has the correct owner', () => { |
| 10 | + expect(problemMatcher.owner).toEqual('htmllint'); |
11 | 11 | }); |
12 | | - it("has one patterns", () => { |
| 12 | + it('has one patterns', () => { |
13 | 13 | expect(problemMatcher.pattern.length).toEqual(1); |
14 | 14 | }); |
15 | | - describe("file pattern", () => { |
| 15 | + describe('file pattern', () => { |
16 | 16 | let pattern; |
17 | 17 | let regexp; |
18 | 18 | beforeEach(() => { |
19 | 19 | pattern = problemMatcher.pattern[0]; |
20 | 20 | regexp = new RegExp(pattern.regexp); |
21 | 21 | }); |
22 | | - it("matches file path", () => { |
| 22 | + it('matches file path', () => { |
23 | 23 | const reportOutput = [ |
24 | | - "src/test.html: line 1, col 1, tag is not closed", |
| 24 | + 'src/test.html: line 1, col 1, tag is not closed', |
25 | 25 | ]; |
26 | 26 | const results = matchResults(reportOutput, regexp); |
27 | 27 | expect(results.length).toEqual(1); |
28 | | - expect(results[0][pattern.file]).toEqual("src/test.html"); |
| 28 | + expect(results[0][pattern.file]).toEqual('src/test.html'); |
29 | 29 | }); |
30 | 30 | }); |
31 | | - describe("violation pattern", () => { |
| 31 | + describe('violation pattern', () => { |
32 | 32 | let pattern; |
33 | 33 | let regexp; |
34 | 34 | beforeEach(() => { |
35 | 35 | pattern = problemMatcher.pattern[0]; |
36 | 36 | regexp = new RegExp(pattern.regexp); |
37 | 37 | }); |
38 | | - it("matches violations", () => { |
| 38 | + it('matches violations', () => { |
39 | 39 | const reportOutput = [ |
40 | | - "src/test.html: line 1, col 1, tag is not closed", |
41 | | - "src/test.html: line 2, col 2, only <head> and <body> may be children of <html>", |
| 40 | + 'src/test.html: line 1, col 1, tag is not closed', |
| 41 | + 'src/test.html: line 2, col 2, only <head> and <body> may be children of <html>', |
42 | 42 | ]; |
43 | 43 | const results = matchResults(reportOutput, regexp); |
44 | 44 | expect(results.length).toEqual(2); |
45 | 45 | }); |
46 | | - it("matches violation details", () => { |
| 46 | + it('matches violation details', () => { |
47 | 47 | const reportOutput = [ |
48 | | - "src/test.html: line 1, col 1, tag is not closed", |
49 | | - "src/foo.html: line 2, col 2, only <head> and <body> may be children of <html>", |
50 | | - "src/bar.html: line 22, col 52, only <head> and <body> may be children of <html>", |
| 48 | + 'src/test.html: line 1, col 1, tag is not closed', |
| 49 | + 'src/foo.html: line 2, col 2, only <head> and <body> may be children of <html>', |
| 50 | + 'src/bar.html: line 22, col 52, only <head> and <body> may be children of <html>', |
51 | 51 | ]; |
52 | 52 | const results = matchResults(reportOutput, regexp); |
53 | 53 | expect(results.length).toEqual(3); |
54 | 54 |
|
55 | | - expect(results[0][pattern.file]).toEqual("src/test.html"); |
56 | | - expect(results[0][pattern.line]).toEqual("1"); |
57 | | - expect(results[0][pattern.column]).toEqual("1"); |
58 | | - expect(results[0][pattern.message]).toEqual("tag is not closed"); |
| 55 | + expect(results[0][pattern.file]).toEqual('src/test.html'); |
| 56 | + expect(results[0][pattern.line]).toEqual('1'); |
| 57 | + expect(results[0][pattern.column]).toEqual('1'); |
| 58 | + expect(results[0][pattern.message]).toEqual('tag is not closed'); |
59 | 59 |
|
60 | | - expect(results[1][pattern.file]).toEqual("src/foo.html"); |
61 | | - expect(results[1][pattern.line]).toEqual("2"); |
62 | | - expect(results[1][pattern.column]).toEqual("2"); |
63 | | - expect(results[1][pattern.message]).toEqual("only <head> and <body> may be children of <html>"); |
| 60 | + expect(results[1][pattern.file]).toEqual('src/foo.html'); |
| 61 | + expect(results[1][pattern.line]).toEqual('2'); |
| 62 | + expect(results[1][pattern.column]).toEqual('2'); |
| 63 | + expect(results[1][pattern.message]).toEqual('only <head> and <body> may be children of <html>'); |
64 | 64 |
|
65 | | - expect(results[2][pattern.file]).toEqual("src/bar.html"); |
66 | | - expect(results[2][pattern.line]).toEqual("22"); |
67 | | - expect(results[2][pattern.column]).toEqual("52"); |
68 | | - expect(results[2][pattern.message]).toEqual("only <head> and <body> may be children of <html>"); |
| 65 | + expect(results[2][pattern.file]).toEqual('src/bar.html'); |
| 66 | + expect(results[2][pattern.line]).toEqual('22'); |
| 67 | + expect(results[2][pattern.column]).toEqual('52'); |
| 68 | + expect(results[2][pattern.message]).toEqual('only <head> and <body> may be children of <html>'); |
69 | 69 | }); |
70 | 70 | }); |
71 | 71 | }); |
0 commit comments