@@ -109,7 +109,7 @@ const uploadSarifMacro = test.macro({
109109 "uploadSpecifiedFiles" ,
110110 ) ;
111111
112- for ( const analysisKind of Object . keys ( expectedResult ) ) {
112+ for ( const analysisKind of Object . values ( AnalysisKind ) ) {
113113 uploadSpecifiedFiles
114114 . withArgs (
115115 sinon . match . any ,
@@ -134,8 +134,10 @@ const uploadSarifMacro = test.macro({
134134 for ( const analysisKind of Object . values ( AnalysisKind ) ) {
135135 const analyisKindResult = expectedResult [ analysisKind ] ;
136136 if ( analyisKindResult ) {
137+ // We are expecting a result for this analysis kind, check that we have it.
137138 t . deepEqual ( actual [ analysisKind ] , analyisKindResult . uploadResult ) ;
138-
139+ // Additionally, check that the mocked `uploadSpecifiedFiles` was called with only the file paths
140+ // that we expected it to be called with.
139141 t . assert (
140142 uploadSpecifiedFiles . calledWith (
141143 analyisKindResult . expectedFiles ?. map ( toFullPath ) ??
@@ -150,7 +152,24 @@ const uploadSarifMacro = test.macro({
150152 ) ,
151153 ) ;
152154 } else {
155+ // Otherwise, we are not expecting a result for this analysis kind. However, note that `undefined`
156+ // is also returned by our mocked `uploadSpecifiedFiles` when there is no expected result for this
157+ // analysis kind.
153158 t . is ( actual [ analysisKind ] , undefined ) ;
159+ // Therefore, we also check that the mocked `uploadSpecifiedFiles` was not called for this analysis kind.
160+ t . assert (
161+ ! uploadSpecifiedFiles . calledWith (
162+ sinon . match . any ,
163+ sinon . match . any ,
164+ sinon . match . any ,
165+ features ,
166+ logger ,
167+ analysisKind === AnalysisKind . CodeScanning
168+ ? CodeScanning
169+ : CodeQuality ,
170+ ) ,
171+ `uploadSpecifiedFiles was called for ${ analysisKind } , but should not have been.` ,
172+ ) ;
154173 }
155174 }
156175 } ) ;
0 commit comments