@@ -10,94 +10,194 @@ import type {
1010} from "github-actions-problem-matcher-typings" ;
1111
1212describe ( "problemMatcher" , ( ) => {
13- let problemMatcher : ProblemMatcher ;
13+ let problemMatcherDocument : ProblemMatcherDocument ;
1414
1515 beforeAll ( async ( ) => {
1616 const matcherFile = fileURLToPath ( new URL ( "../src/problem-matcher.json" , import . meta. url ) ) ;
1717 const fileContents = await readFile ( matcherFile , { encoding : "utf8" } ) ;
18- const problemMatcherDocument = JSON . parse ( fileContents ) as ProblemMatcherDocument ;
1918
20- problemMatcher = problemMatcherDocument . problemMatcher [ 0 ] ;
19+ problemMatcherDocument = JSON . parse ( fileContents ) ;
2120 } ) ;
2221
23- it ( "has the correct owner " , ( ) => {
24- expect ( problemMatcher . owner ) . toEqual ( "stylelint" ) ;
22+ it ( "has two matchers " , ( ) => {
23+ expect ( problemMatcherDocument . problemMatcher . length ) . toEqual ( 2 ) ;
2524 } ) ;
2625
27- it ( "has two patterns" , ( ) => {
28- expect ( problemMatcher . pattern . length ) . toEqual ( 2 ) ;
29- } ) ;
30-
31- describe ( "file pattern" , ( ) => {
32- let pattern : ProblemPattern ;
33- let regexp : RegExp ;
26+ describe ( "error matcher" , ( ) => {
27+ let problemMatcher : ProblemMatcher ;
3428
35- beforeEach ( ( ) => {
36- pattern = problemMatcher . pattern [ 0 ] ;
37- regexp = new RegExp ( pattern . regexp ) ;
29+ beforeAll ( ( ) => {
30+ problemMatcher = problemMatcherDocument . problemMatcher [ 0 ] ;
3831 } ) ;
3932
40- it ( "matches file path" , ( ) => {
41- const reportOutput = [
42- "scss/_test.scss" ,
43- " 11:16 × Unexpected unit length-zero-no-unit" ,
44- " 11:28 × Unexpected unit length-zero-no-unit" ,
45- ] ;
46-
47- const results = matchResults ( reportOutput , regexp ) ;
33+ it ( "has the correct owner" , ( ) => {
34+ expect ( problemMatcher . owner ) . toEqual ( "stylelint-error" ) ;
35+ } ) ;
4836
49- expect ( results . length ) . toEqual ( 1 ) ;
50- expect ( results [ 0 ] [ pattern . file ! ] ) . toEqual ( "scss/_test.scss" ) ;
37+ it ( "has two patterns" , ( ) => {
38+ expect ( problemMatcher . pattern . length ) . toEqual ( 2 ) ;
5139 } ) ;
40+
41+ describe ( "file pattern" , ( ) => {
42+ let pattern : ProblemPattern ;
43+ let regexp : RegExp ;
44+
45+ beforeEach ( ( ) => {
46+ pattern = problemMatcher . pattern [ 0 ] ;
47+ regexp = new RegExp ( pattern . regexp ) ;
48+ } ) ;
49+
50+ it ( "matches file path" , ( ) => {
51+ const reportOutput = [
52+ "scss/_test.scss" ,
53+ " 11:16 ✖ Unexpected unit length-zero-no-unit" ,
54+ " 11:28 ✖ Unexpected unit length-zero-no-unit" ,
55+ ] ;
56+
57+ const results = matchResults ( reportOutput , regexp ) ;
58+
59+ expect ( results . length ) . toEqual ( 1 ) ;
60+ expect ( results [ 0 ] [ pattern . file ! ] ) . toEqual ( "scss/_test.scss" ) ;
61+ } ) ;
62+ } ) ;
63+
64+ describe ( "violation pattern" , ( ) => {
65+ let pattern : ProblemPattern ;
66+ let regexp : RegExp ;
67+
68+ beforeEach ( ( ) => {
69+ pattern = problemMatcher . pattern [ 1 ] ;
70+ regexp = new RegExp ( pattern . regexp ) ;
71+ } ) ;
72+
73+ it ( "matches violations" , ( ) => {
74+ const reportOutput = [
75+ "scss/_test.scss" ,
76+ " 11:16 ✖ Unexpected unit length-zero-no-unit" ,
77+ " 11:28 ✖ Unexpected unit length-zero-no-unit" ,
78+ ] ;
79+
80+ const results = matchResults ( reportOutput , regexp ) ;
81+
82+ expect ( results . length ) . toEqual ( 2 ) ;
83+ } ) ;
84+
85+ it ( "matches violations without line numbers" , ( ) => {
86+ const reportOutput = [
87+ "scss/_test.scss" ,
88+ " ✖ Unexpected Unicode BOM unicode-bom" ,
89+ " 11:16 ✖ Unexpected unit length-zero-no-unit" ,
90+ " 11:28 ✖ Unexpected unit length-zero-no-unit" ,
91+ ] ;
92+
93+ const results = matchResults ( reportOutput , regexp ) ;
94+
95+ expect ( results . length ) . toEqual ( 3 ) ;
96+ } ) ;
97+
98+ it ( "matches violation details" , ( ) => {
99+ const reportOutput = [
100+ "scss/_test.scss" ,
101+ " 11:16 ✖ Unexpected unit length-zero-no-unit" ,
102+ ] ;
103+
104+ const results = matchResults ( reportOutput , regexp ) ;
105+
106+ expect ( results . length ) . toEqual ( 1 ) ;
107+ expect ( results [ 0 ] [ pattern . line ! ] ) . toEqual ( "11" ) ;
108+ expect ( results [ 0 ] [ pattern . column ! ] ) . toEqual ( "16" ) ;
109+ expect ( results [ 0 ] [ pattern . message ! ] ) . toEqual ( "Unexpected unit " ) ;
110+ expect ( results [ 0 ] [ pattern . code ! ] ) . toEqual ( "length-zero-no-unit" ) ;
111+ } ) ;
112+ } ) ;
52113 } ) ;
53114
54- describe ( "violation pattern" , ( ) => {
55- let pattern : ProblemPattern ;
56- let regexp : RegExp ;
115+ describe ( "warning matcher" , ( ) => {
116+ let problemMatcher : ProblemMatcher ;
57117
58- beforeEach ( ( ) => {
59- pattern = problemMatcher . pattern [ 1 ] ;
60- regexp = new RegExp ( pattern . regexp ) ;
118+ beforeAll ( ( ) => {
119+ problemMatcher = problemMatcherDocument . problemMatcher [ 1 ] ;
61120 } ) ;
62121
63- it ( "matches violations" , ( ) => {
64- const reportOutput = [
65- "scss/_test.scss" ,
66- " 11:16 × Unexpected unit length-zero-no-unit" ,
67- " 11:28 × Unexpected unit length-zero-no-unit" ,
68- ] ;
69-
70- const results = matchResults ( reportOutput , regexp ) ;
122+ it ( "has the correct owner" , ( ) => {
123+ expect ( problemMatcher . owner ) . toEqual ( "stylelint-warning" ) ;
124+ } ) ;
71125
72- expect ( results . length ) . toEqual ( 2 ) ;
126+ it ( "has two patterns" , ( ) => {
127+ expect ( problemMatcher . pattern . length ) . toEqual ( 2 ) ;
73128 } ) ;
74129
75- it ( "matches violations without line numbers" , ( ) => {
76- const reportOutput = [
77- "scss/_test.scss" ,
78- " × Unexpected Unicode BOM unicode-bom" ,
79- " 11:16 × Unexpected unit length-zero-no-unit" ,
80- " 11:28 × Unexpected unit length-zero-no-unit" ,
81- ] ;
130+ describe ( "file pattern" , ( ) => {
131+ let pattern : ProblemPattern ;
132+ let regexp : RegExp ;
82133
83- const results = matchResults ( reportOutput , regexp ) ;
134+ beforeEach ( ( ) => {
135+ pattern = problemMatcher . pattern [ 0 ] ;
136+ regexp = new RegExp ( pattern . regexp ) ;
137+ } ) ;
84138
85- expect ( results . length ) . toEqual ( 3 ) ;
86- } ) ;
139+ it ( "matches file path" , ( ) => {
140+ const reportOutput = [
141+ "scss/_test.scss" ,
142+ " 11:16 ⚠ Unexpected unit length-zero-no-unit" ,
143+ " 11:28 ⚠ Unexpected unit length-zero-no-unit" ,
144+ ] ;
87145
88- it ( "matches violation details" , ( ) => {
89- const reportOutput = [
90- "scss/_test.scss" ,
91- " 11:16 × Unexpected unit length-zero-no-unit" ,
92- ] ;
146+ const results = matchResults ( reportOutput , regexp ) ;
93147
94- const results = matchResults ( reportOutput , regexp ) ;
148+ expect ( results . length ) . toEqual ( 1 ) ;
149+ expect ( results [ 0 ] [ pattern . file ! ] ) . toEqual ( "scss/_test.scss" ) ;
150+ } ) ;
151+ } ) ;
95152
96- expect ( results . length ) . toEqual ( 1 ) ;
97- expect ( results [ 0 ] [ pattern . line ! ] ) . toEqual ( "11" ) ;
98- expect ( results [ 0 ] [ pattern . column ! ] ) . toEqual ( "16" ) ;
99- expect ( results [ 0 ] [ pattern . message ! ] ) . toEqual ( "Unexpected unit " ) ;
100- expect ( results [ 0 ] [ pattern . code ! ] ) . toEqual ( "length-zero-no-unit" ) ;
153+ describe ( "violation pattern" , ( ) => {
154+ let pattern : ProblemPattern ;
155+ let regexp : RegExp ;
156+
157+ beforeEach ( ( ) => {
158+ pattern = problemMatcher . pattern [ 1 ] ;
159+ regexp = new RegExp ( pattern . regexp ) ;
160+ } ) ;
161+
162+ it ( "matches violations" , ( ) => {
163+ const reportOutput = [
164+ "scss/_test.scss" ,
165+ " 11:16 ⚠ Unexpected unit length-zero-no-unit" ,
166+ " 11:28 ⚠ Unexpected unit length-zero-no-unit" ,
167+ ] ;
168+
169+ const results = matchResults ( reportOutput , regexp ) ;
170+
171+ expect ( results . length ) . toEqual ( 2 ) ;
172+ } ) ;
173+
174+ it ( "matches violations without line numbers" , ( ) => {
175+ const reportOutput = [
176+ "scss/_test.scss" ,
177+ " ⚠ Unexpected Unicode BOM unicode-bom" ,
178+ " 11:16 ⚠ Unexpected unit length-zero-no-unit" ,
179+ " 11:28 ⚠ Unexpected unit length-zero-no-unit" ,
180+ ] ;
181+
182+ const results = matchResults ( reportOutput , regexp ) ;
183+
184+ expect ( results . length ) . toEqual ( 3 ) ;
185+ } ) ;
186+
187+ it ( "matches violation details" , ( ) => {
188+ const reportOutput = [
189+ "scss/_test.scss" ,
190+ " 11:16 ⚠ Unexpected unit length-zero-no-unit" ,
191+ ] ;
192+
193+ const results = matchResults ( reportOutput , regexp ) ;
194+
195+ expect ( results . length ) . toEqual ( 1 ) ;
196+ expect ( results [ 0 ] [ pattern . line ! ] ) . toEqual ( "11" ) ;
197+ expect ( results [ 0 ] [ pattern . column ! ] ) . toEqual ( "16" ) ;
198+ expect ( results [ 0 ] [ pattern . message ! ] ) . toEqual ( "Unexpected unit " ) ;
199+ expect ( results [ 0 ] [ pattern . code ! ] ) . toEqual ( "length-zero-no-unit" ) ;
200+ } ) ;
101201 } ) ;
102202 } ) ;
103203} ) ;
0 commit comments