@@ -419,42 +419,15 @@ describe('SARIF processing', () => {
419419 expectResultParsingError ( result . errors [ 0 ] ) ;
420420 } ) ;
421421
422- it ( 'should not return errors for result locations with no snippet' , ( ) => {
423- const sarif = buildValidSarifLog ( ) ;
424- sarif . runs ! [ 0 ] ! . results ! [ 0 ] ! . locations ! [ 0 ] ! . physicalLocation ! . contextRegion ! . snippet = undefined ;
425-
426- const result = extractAnalysisAlerts ( sarif , fakefileLinkPrefix ) ;
427-
428- const expectedCodeSnippet = {
429- startLine : result . alerts [ 0 ] . codeSnippet ! . startLine ,
430- endLine : result . alerts [ 0 ] . codeSnippet ! . endLine ,
431- text : ''
432- } ;
433-
434- const actualCodeSnippet = result . alerts [ 0 ] . codeSnippet ;
435-
436- expect ( result ) . to . be . ok ;
437- expectNoParsingError ( result ) ;
438- expect ( actualCodeSnippet ) . to . deep . equal ( expectedCodeSnippet ) ;
439- } ) ;
440-
441- it ( 'should not return errors for result locations with no contextRegion' , ( ) => {
422+ it ( 'should return errors for result locations with no context region' , ( ) => {
442423 const sarif = buildValidSarifLog ( ) ;
443424 sarif . runs ! [ 0 ] ! . results ! [ 0 ] ! . locations ! [ 0 ] ! . physicalLocation ! . contextRegion = undefined ;
444425
445426 const result = extractAnalysisAlerts ( sarif , fakefileLinkPrefix ) ;
446427
447- const expectedCodeSnippet = {
448- startLine : result . alerts [ 0 ] . highlightedRegion ! . startLine ,
449- endLine : result . alerts [ 0 ] . highlightedRegion ! . endLine ,
450- text : ''
451- } ;
452-
453- const actualCodeSnippet = result . alerts [ 0 ] . codeSnippet ;
454-
455428 expect ( result ) . to . be . ok ;
456- expectNoParsingError ( result ) ;
457- expect ( actualCodeSnippet ) . to . deep . equal ( expectedCodeSnippet ) ;
429+ expect ( result . errors . length ) . to . equal ( 1 ) ;
430+ expectResultParsingError ( result . errors [ 0 ] ) ;
458431 } ) ;
459432
460433 it ( 'should not return errors for result locations with no region' , ( ) => {
@@ -465,7 +438,6 @@ describe('SARIF processing', () => {
465438
466439 expect ( result ) . to . be . ok ;
467440 expect ( result . alerts . length ) . to . equal ( 1 ) ;
468- expectNoParsingError ( result ) ;
469441 } ) ;
470442
471443 it ( 'should return errors for result locations with no physical location' , ( ) => {
@@ -565,9 +537,9 @@ describe('SARIF processing', () => {
565537 expect ( result ) . to . be . ok ;
566538 expect ( result . errors . length ) . to . equal ( 0 ) ;
567539 expect ( result . alerts . length ) . to . equal ( 3 ) ;
568- expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg1' && a . codeSnippet ! . text === 'foo' ) ) . to . be . ok ;
569- expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg1' && a . codeSnippet ! . text === 'bar' ) ) . to . be . ok ;
570- expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg2' && a . codeSnippet ! . text === 'baz' ) ) . to . be . ok ;
540+ expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg1' && a . codeSnippet . text === 'foo' ) ) . to . be . ok ;
541+ expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg1' && a . codeSnippet . text === 'bar' ) ) . to . be . ok ;
542+ expect ( result . alerts . find ( a => getMessageText ( a . message ) === 'msg2' && a . codeSnippet . text === 'baz' ) ) . to . be . ok ;
571543 expect ( result . alerts . every ( a => a . severity === 'Warning' ) ) . to . be . true ;
572544 } ) ;
573545
@@ -623,14 +595,9 @@ describe('SARIF processing', () => {
623595 expect ( msg . startsWith ( 'Error when processing SARIF result' ) ) . to . be . true ;
624596 }
625597
626- function expectNoParsingError ( result : { errors : string [ ] | undefined } ) {
627- const array = result . errors || [ ] ;
628- expect ( array . length , array . join ( ) ) . to . equal ( 0 ) ;
629- }
630-
631598 function buildValidSarifLog ( ) : sarif . Log {
632599 return {
633- version : '2.1.0' ,
600+ version : '0.0.1' as sarif . Log . version ,
634601 runs : [
635602 {
636603 results : [
0 commit comments