@@ -69,7 +69,7 @@ describe('ResultsViewer implementations', () => {
6969 // ==== TEST SETUP ====
7070 // This test doesn't care about sorting, so just assign our engine several copies of the same violation.
7171 const violations : Violation [ ] = repeatViolation (
72- createViolation ( rule1 . name , PATH_TO_SOME_FILE , 1 , 1 ) ,
72+ createViolation ( rule1 . name , PATH_TO_SOME_FILE , 1 , 1 , [ 'https://violation_specific.url' ] ) ,
7373 4 ) ;
7474 engine1 . resultsToReturn = { violations} ;
7575 const workspace = await codeAnalyzerCore . createWorkspace ( [ PATH_TO_SOME_FILE ] ) ;
@@ -90,8 +90,9 @@ describe('ResultsViewer implementations', () => {
9090 // Rip off all of ansis's styling, so we're just comparing plain text.
9191 const actualEventText = ansis . strip ( actualDisplayEvents . map ( e => e . data ) . join ( '\n' ) ) ;
9292 const expectedViolationDetails = ( await readComparisonFile ( 'four-identical-violations-details.txt' ) )
93- . replace ( / _ _ P A T H _ T O _ S O M E _ F I L E _ _ / g, PATH_TO_SOME_FILE ) ;
94- expect ( actualEventText ) . toContain ( expectedViolationDetails ) ;
93+ . replaceAll ( "{{PATHSEP}}" , path . sep )
94+ . replace ( "{{RUNDIR}}" , results . getRunDirectory ( ) ) ;
95+ expect ( actualEventText ) . toEqual ( expectedViolationDetails ) ;
9596 } ) ;
9697
9798 // The reasoning behind this sorting order is so that the Detail view can function as a "show me the N most
@@ -128,9 +129,9 @@ describe('ResultsViewer implementations', () => {
128129 // Rip off all of ansis's styling, so we're just comparing plain text.
129130 const actualEventText = ansis . strip ( actualDisplayEvents . map ( e => e . data ) . join ( '\n' ) ) ;
130131 const expectedViolationDetails = ( await readComparisonFile ( 'four-unique-violations-details.txt' ) )
131- . replace ( / _ _ P A T H _ T O _ F I L E _ A _ _ / g , PATH_TO_FILE_A )
132- . replace ( / _ _ P A T H _ T O _ F I L E _ Z _ _ / g , PATH_TO_FILE_Z ) ;
133- expect ( actualEventText ) . toContain ( expectedViolationDetails ) ;
132+ . replaceAll ( "{{PATHSEP}}" , path . sep )
133+ . replace ( "{{RUNDIR}}" , results . getRunDirectory ( ) ) ;
134+ expect ( actualEventText ) . toEqual ( expectedViolationDetails ) ;
134135 } ) ;
135136
136137 it ( 'Multi-location violations are correctly displayed' , async ( ) => {
@@ -146,11 +147,13 @@ describe('ResultsViewer implementations', () => {
146147 file : PATH_TO_FILE_Z ,
147148 startLine : 2 ,
148149 startColumn : 1 ,
149- comment : 'This is a comment at Location 2'
150+ endColumn : 7 ,
151+ comment : 'This is a comment at Location 2' ,
150152 } , {
151153 file : PATH_TO_FILE_A ,
152154 startLine : 1 ,
153155 startColumn : 1 ,
156+ endLine : 3 ,
154157 comment : 'This is a comment at Location 3'
155158 } ) ;
156159 // Declare the second location to be the primary.
@@ -175,9 +178,9 @@ describe('ResultsViewer implementations', () => {
175178 // Rip off all of ansis's styling, so we're just comparing plain text.
176179 const actualEventText = ansis . strip ( actualDisplayEvents . map ( e => e . data ) . join ( '\n' ) ) ;
177180 const expectedViolationDetails = ( await readComparisonFile ( 'one-multilocation-violation-details.txt' ) )
178- . replace ( / _ _ P A T H _ T O _ F I L E _ A _ _ / g , PATH_TO_FILE_A )
179- . replace ( / _ _ P A T H _ T O _ F I L E _ Z _ _ / g , PATH_TO_FILE_Z ) ;
180- expect ( actualEventText ) . toContain ( expectedViolationDetails ) ;
181+ . replaceAll ( "{{PATHSEP}}" , path . sep )
182+ . replace ( "{{RUNDIR}}" , results . getRunDirectory ( ) ) ;
183+ expect ( actualEventText ) . toEqual ( expectedViolationDetails ) ;
181184 } )
182185 } ) ;
183186
@@ -227,7 +230,7 @@ describe('ResultsViewer implementations', () => {
227230 expect ( displayEvents [ 0 ] . type ) . toEqual ( DisplayEventType . LOG ) ;
228231 expect ( displayEvents [ 0 ] . data ) . toEqual ( '' ) ;
229232 expect ( displayEvents [ 1 ] . type ) . toEqual ( DisplayEventType . LOG ) ;
230- expect ( displayEvents [ 1 ] . data ) . toEqual ( getMessage ( BundleName . ResultsViewer , 'summary.table .results-relative-to' , [ PATH_TO_SAMPLE_CODE ] ) ) ;
233+ expect ( displayEvents [ 1 ] . data ) . toEqual ( getMessage ( BundleName . ResultsViewer , 'summary.shared .results-relative-to' , [ PATH_TO_SAMPLE_CODE ] ) ) ;
231234 expect ( displayEvents [ 2 ] . type ) . toEqual ( DisplayEventType . TABLE ) ;
232235 expect ( displayEvents [ 2 ] . data ) . toEqual ( `{"columns":["#","Severity","Rule","Location","Message"],"rows":[{"num":1,"location":"someFile.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"},{"num":2,"location":"someFile.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"},{"num":3,"location":"someFile.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"},{"num":4,"location":"someFile.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"}]}` ) ;
233236 } ) ;
@@ -261,7 +264,7 @@ describe('ResultsViewer implementations', () => {
261264 expect ( displayEvents [ 0 ] . type ) . toEqual ( DisplayEventType . LOG ) ;
262265 expect ( displayEvents [ 0 ] . data ) . toEqual ( '' ) ;
263266 expect ( displayEvents [ 1 ] . type ) . toEqual ( DisplayEventType . LOG ) ;
264- expect ( displayEvents [ 1 ] . data ) . toEqual ( getMessage ( BundleName . ResultsViewer , 'summary.table .results-relative-to' , [ PATH_TO_SAMPLE_CODE ] ) ) ;
267+ expect ( displayEvents [ 1 ] . data ) . toEqual ( getMessage ( BundleName . ResultsViewer , 'summary.shared .results-relative-to' , [ PATH_TO_SAMPLE_CODE ] ) ) ;
265268 expect ( displayEvents [ 2 ] . type ) . toEqual ( DisplayEventType . TABLE ) ;
266269 expect ( displayEvents [ 2 ] . data ) . toEqual ( `{"columns":["#","Severity","Rule","Location","Message"],"rows":[{"num":1,"location":"fileZ.cls:20:1","rule":"stubEngine1:stub1RuleB","severity":"2 (High)","message":"This is a message"},{"num":2,"location":"fileA.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"},{"num":3,"location":"fileA.cls:20:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"},{"num":4,"location":"fileZ.cls:1:1","rule":"stubEngine1:stub1RuleA","severity":"4 (Low)","message":"This is a message"}]}` ) ;
267270 } ) ;
@@ -301,7 +304,7 @@ describe('Tests for the findLongestCommonParentFolderOf helper function', () =>
301304 }
302305} ) ;
303306
304- function createViolation ( ruleName : string , file : string , startLine : number , startColumn : number ) : Violation {
307+ function createViolation ( ruleName : string , file : string , startLine : number , startColumn : number , resourceUrls : string [ ] = [ ] ) : Violation {
305308 return {
306309 ruleName,
307310 message : 'This is a message' ,
@@ -310,7 +313,8 @@ function createViolation(ruleName: string, file: string, startLine: number, star
310313 startLine,
311314 startColumn
312315 } ] ,
313- primaryLocationIndex : 0
316+ primaryLocationIndex : 0 ,
317+ resourceUrls : resourceUrls
314318 } ;
315319}
316320
0 commit comments