Skip to content

Commit e28fefc

Browse files
jdaltonclaude
andcommitted
Fix test mocks for withSdk usage
Add handleApiCall mock for tests using withSdk. The withSdk helper dynamically imports handleApiCall from api.mts at runtime, so tests must mock both sdk.mts and api.mts modules. Fixes: - fetch-delete-org-full-scan.test.mts - fetch-purls-shallow-score.test.mts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1bdc9df commit e28fefc

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/commands/package/fetch-purls-shallow-score.test.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ vi.mock('../../utils/sdk.mts', () => ({
88
withSdk: vi.fn(),
99
}))
1010

11+
vi.mock('../../utils/api.mts', () => ({
12+
handleApiCall: vi.fn(),
13+
}))
14+
1115
describe('fetchPurlsShallowScore', () => {
1216
it('fetches purls shallow scores successfully', async () => {
1317
const { handleApiCall } = await import('../../utils/api.mts')

src/commands/scan/fetch-delete-org-full-scan.test.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ vi.mock('../../utils/sdk.mts', () => ({
88
withSdk: vi.fn(),
99
}))
1010

11+
vi.mock('../../utils/api.mts', () => ({
12+
handleApiCall: vi.fn(),
13+
}))
14+
1115
describe('fetchDeleteOrgFullScan', () => {
1216
it('deletes scan successfully', async () => {
1317
const { handleApiCall } = await import('../../utils/api.mts')

0 commit comments

Comments
 (0)