Skip to content

Commit 33b7ec4

Browse files
committed
Fixing test cases
1 parent 5428d8d commit 33b7ec4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/amazonq/test/unit/codewhisperer/util/zipUtil.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import vscode from 'vscode'
88
import sinon from 'sinon'
99
import { join } from 'path'
1010
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'
1212
import { codeScanTruncDirPrefix } from 'aws-core-vscode/codewhisperer'
1313
import { ToolkitError } from 'aws-core-vscode/shared'
1414
import { LspClient } from 'aws-core-vscode/amazonq'
@@ -116,6 +116,8 @@ describe('zipUtil', function () {
116116
})
117117

118118
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)
119121
const zipMetadata = await zipUtil.generateZip(
120122
vscode.Uri.file(appCodePathWithRepeatedProjectName),
121123
CodeAnalysisScope.FILE_ON_DEMAND
@@ -125,9 +127,19 @@ describe('zipUtil', function () {
125127
const zip = await JSZip.loadAsync(zipFileData)
126128
const files = Object.keys(zip.files)
127129
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()
128137
})
129138

130139
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+
131143
const zipMetadata = await zipUtil.generateZip(
132144
vscode.Uri.file(appCodePathWithRepeatedProjectName),
133145
CodeAnalysisScope.PROJECT
@@ -137,6 +149,11 @@ describe('zipUtil', function () {
137149
const zip = await JSZip.loadAsync(zipFileData)
138150
const files = Object.keys(zip.files)
139151
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()
140157
})
141158
})
142159

0 commit comments

Comments
 (0)