@@ -8,7 +8,7 @@ import vscode from 'vscode'
8
8
import sinon from 'sinon'
9
9
import { join } from 'path'
10
10
import { getTestWorkspaceFolder } from 'aws-core-vscode/test'
11
- import { CodeAnalysisScope , ZipUtil } from 'aws-core-vscode/codewhisperer'
11
+ import { CodeAnalysisScope , FeatureUseCase , ZipUtil } from 'aws-core-vscode/codewhisperer'
12
12
import { codeScanTruncDirPrefix } from 'aws-core-vscode/codewhisperer'
13
13
import { ToolkitError } from 'aws-core-vscode/shared'
14
14
import { LspClient } from 'aws-core-vscode/amazonq'
@@ -116,6 +116,8 @@ describe('zipUtil', function () {
116
116
} )
117
117
118
118
it ( 'should handle path with repeated project name for file scan' , async function ( ) {
119
+ const mockCodeScan = 'CODE_SCAN'
120
+ sinon . stub ( FeatureUseCase , 'CODE_SCAN' ) . value ( mockCodeScan )
119
121
const zipMetadata = await zipUtil . generateZip (
120
122
vscode . Uri . file ( appCodePathWithRepeatedProjectName ) ,
121
123
CodeAnalysisScope . FILE_ON_DEMAND
@@ -125,9 +127,19 @@ describe('zipUtil', function () {
125
127
const zip = await JSZip . loadAsync ( zipFileData )
126
128
const files = Object . keys ( zip . files )
127
129
assert . ok ( files . includes ( join ( 'workspaceFolder' , 'workspaceFolder' , 'App.java' ) ) )
130
+
131
+ // Verify that the mocked FeatureUseCase.CODE_SCAN was used
132
+ assert . ok ( zipMetadata . rootDir . includes ( mockCodeScan ) )
133
+ assert . ok ( zipMetadata . zipFilePath . includes ( mockCodeScan ) )
134
+
135
+ // Restore the original FeatureUseCase.CODE_SCAN
136
+ sinon . restore ( )
128
137
} )
129
138
130
139
it ( 'should handle path with repeated project name for project scan' , async function ( ) {
140
+ const mockCodeScan = 'CODE_SCAN'
141
+ sinon . stub ( FeatureUseCase , 'CODE_SCAN' ) . value ( mockCodeScan )
142
+
131
143
const zipMetadata = await zipUtil . generateZip (
132
144
vscode . Uri . file ( appCodePathWithRepeatedProjectName ) ,
133
145
CodeAnalysisScope . PROJECT
@@ -137,6 +149,11 @@ describe('zipUtil', function () {
137
149
const zip = await JSZip . loadAsync ( zipFileData )
138
150
const files = Object . keys ( zip . files )
139
151
assert . ok ( files . includes ( join ( 'workspaceFolder' , 'workspaceFolder' , 'App.java' ) ) )
152
+
153
+ assert . ok ( zipMetadata . rootDir . includes ( mockCodeScan ) )
154
+ assert . ok ( zipMetadata . zipFilePath . includes ( mockCodeScan ) )
155
+
156
+ sinon . restore ( )
140
157
} )
141
158
} )
142
159
0 commit comments