@@ -19,11 +19,15 @@ import sinon from 'sinon'
1919import path from 'path'
2020
2121describe ( 'SecurityIssueTreeViewProvider' , function ( ) {
22- let securityIssueProvider : SecurityIssueProvider
2322 let securityIssueTreeViewProvider : SecurityIssueTreeViewProvider
2423
2524 beforeEach ( function ( ) {
26- securityIssueProvider = SecurityIssueProvider . instance
25+ SecurityIssueProvider . instance . issues = [
26+ { filePath : 'file/path/a' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
27+ { filePath : 'file/path/b' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
28+ { filePath : 'file/path/c' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
29+ { filePath : 'file/path/d' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
30+ ]
2731 securityIssueTreeViewProvider = new SecurityIssueTreeViewProvider ( )
2832 } )
2933
@@ -47,13 +51,6 @@ describe('SecurityIssueTreeViewProvider', function () {
4751
4852 describe ( 'getChildren' , function ( ) {
4953 it ( 'should return sorted list of severities if element is undefined' , function ( ) {
50- securityIssueProvider . issues = [
51- { filePath : 'file/path/c' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
52- { filePath : 'file/path/d' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
53- { filePath : 'file/path/a' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
54- { filePath : 'file/path/b' , issues : [ createCodeScanIssue ( ) , createCodeScanIssue ( ) ] } ,
55- ]
56-
5754 const element = undefined
5855 const result = securityIssueTreeViewProvider . getChildren ( element ) as SeverityItem [ ]
5956 assert . strictEqual ( result . length , 5 )
@@ -108,28 +105,11 @@ describe('SecurityIssueTreeViewProvider', function () {
108105
109106 it ( 'should return severity-grouped items when grouping strategy is Severity' , function ( ) {
110107 sinon . stub ( CodeIssueGroupingStrategyState . instance , 'getState' ) . returns ( CodeIssueGroupingStrategy . Severity )
111- securityIssueProvider . issues = [
112- {
113- filePath : 'file/path/c' ,
114- issues : [
115- createCodeScanIssue ( { severity : 'Critical' } ) ,
116- createCodeScanIssue ( { severity : 'Critical' } ) ,
117- ] ,
118- } ,
119- {
120- filePath : 'file/path/d' ,
121- issues : [ createCodeScanIssue ( { severity : 'Critical' } ) ] ,
122- } ,
123- {
124- filePath : 'file/path/a' ,
125- issues : [ createCodeScanIssue ( { severity : 'Critical' } ) , createCodeScanIssue ( { severity : 'High' } ) ] ,
126- } ,
127- ]
128108
129109 const severityItems = securityIssueTreeViewProvider . getChildren ( ) as SeverityItem [ ]
130110 for ( const [ index , [ severity , expectedIssueCount ] ] of [
131- [ 'Critical' , 4 ] ,
132- [ 'High' , 1 ] ,
111+ [ 'Critical' , 0 ] ,
112+ [ 'High' , 8 ] ,
133113 [ 'Medium' , 0 ] ,
134114 [ 'Low' , 0 ] ,
135115 [ 'Info' , 0 ] ,
@@ -150,29 +130,13 @@ describe('SecurityIssueTreeViewProvider', function () {
150130 sinon
151131 . stub ( CodeIssueGroupingStrategyState . instance , 'getState' )
152132 . returns ( CodeIssueGroupingStrategy . FileLocation )
153- securityIssueProvider . issues = [
154- {
155- filePath : 'file/path/c' ,
156- issues : [
157- createCodeScanIssue ( { severity : 'Critical' } ) ,
158- createCodeScanIssue ( { severity : 'Critical' } ) ,
159- ] ,
160- } ,
161- {
162- filePath : 'file/path/d' ,
163- issues : [ createCodeScanIssue ( { severity : 'Critical' } ) ] ,
164- } ,
165- {
166- filePath : 'file/path/a' ,
167- issues : [ createCodeScanIssue ( { severity : 'Critical' } ) , createCodeScanIssue ( { severity : 'High' } ) ] ,
168- } ,
169- ]
170133
171134 const result = securityIssueTreeViewProvider . getChildren ( ) as FileItem [ ]
172135 for ( const [ index , [ fileName , expectedIssueCount ] ] of [
173136 [ 'a' , 2 ] ,
137+ [ 'b' , 2 ] ,
174138 [ 'c' , 2 ] ,
175- [ 'd' , 1 ] ,
139+ [ 'd' , 2 ] ,
176140 ] . entries ( ) ) {
177141 const currentFileItem = result [ index ]
178142 assert . strictEqual ( currentFileItem . label , fileName )
0 commit comments