Skip to content

Commit 286904a

Browse files
committed
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
1 parent 7b31f7e commit 286904a

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)