@@ -107,29 +107,61 @@ test('linting of incorrect Markdown file fails', async t => {
107107
108108test ( 'linting of incorrect Markdown file fails prints issues as json' , async t => {
109109 try {
110- await spawn ( '../markdownlint.js' , [ '--config' , 'test -config.json' , 'incorrect.md' , '--json' ] ) ;
110+ await spawn ( '../markdownlint.js' , [ '--config' , 'warning -config.json' , 'incorrect.md' , '--json' ] ) ;
111111 t . fail ( ) ;
112112 } catch ( error ) {
113113 t . is ( error . stdout , '' ) ;
114114 const issues = JSON . parse ( error . stderr ) ;
115- t . is ( issues . length , 7 ) ;
116- const issue = issues [ 0 ] ;
117- // Property "ruleInformation" changes with library version
118- t . true ( issue . ruleInformation . length > 0 ) ;
119- issue . ruleInformation = null ;
120- const expected = {
121- fileName : 'incorrect.md' ,
122- lineNumber : 1 ,
123- ruleNames : [ 'MD041' , 'first-line-heading' , 'first-line-h1' ] ,
124- ruleDescription : 'First line in a file should be a top-level heading' ,
125- ruleInformation : null ,
126- errorContext : '## header 2' ,
127- errorDetail : null ,
128- errorRange : null ,
129- fixInfo : null ,
130- severity : 'error'
131- } ;
132- t . deepEqual ( issues [ 0 ] , expected ) ;
115+ for ( const issue of issues ) {
116+ // Property "ruleInformation" changes with library version
117+ t . true ( issue . ruleInformation . length > 0 ) ;
118+ issue . ruleInformation = null ;
119+ }
120+
121+ const expected = [
122+ {
123+ fileName : 'incorrect.md' ,
124+ lineNumber : 1 ,
125+ ruleNames : [ 'MD041' , 'first-line-heading' , 'first-line-h1' ] ,
126+ ruleDescription : 'First line in a file should be a top-level heading' ,
127+ ruleInformation : null ,
128+ errorDetail : null ,
129+ errorContext : '## header 2' ,
130+ errorRange : null ,
131+ fixInfo : null ,
132+ severity : 'warning'
133+ } ,
134+ {
135+ fileName : 'incorrect.md' ,
136+ lineNumber : 1 ,
137+ ruleNames : [ 'MD022' , 'blanks-around-headings' ] ,
138+ ruleDescription : 'Headings should be surrounded by blank lines' ,
139+ ruleInformation : null ,
140+ errorDetail : 'Expected: 1; Actual: 0; Below' ,
141+ errorContext : '## header 2' ,
142+ errorRange : null ,
143+ fixInfo : {
144+ lineNumber : 2 ,
145+ insertText : '\n'
146+ } ,
147+ severity : 'error'
148+ } ,
149+ {
150+ fileName : 'incorrect.md' ,
151+ lineNumber : 2 ,
152+ ruleNames : [ 'MD022' , 'blanks-around-headings' ] ,
153+ ruleDescription : 'Headings should be surrounded by blank lines' ,
154+ ruleInformation : null ,
155+ errorDetail : 'Expected: 1; Actual: 0; Above' ,
156+ errorContext : '# header' ,
157+ errorRange : null ,
158+ fixInfo : {
159+ insertText : '\n'
160+ } ,
161+ severity : 'error'
162+ }
163+ ] ;
164+ t . deepEqual ( issues , expected ) ;
133165 t . is ( error . exitCode , 1 ) ;
134166 }
135167} ) ;
0 commit comments