Skip to content

Commit 7b31f7e

Browse files
committed
Fix fetchPurlDeepScore test mock setup
Update test to use setupSdk instead of withSdk to match the implementation. The function uses setupSdk for SDK initialization, so tests must mock the correct export.
1 parent 6cf4099 commit 7b31f7e

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/commands/package/fetch-purl-deep-score.test.mts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fetchPurlDeepScore } from './fetch-purl-deep-score.mts'
55
// Mock the dependencies.
66
vi.mock('../../utils/sdk.mts', () => ({
77
queryApiJson: vi.fn(),
8-
withSdk: vi.fn(),
8+
setupSdk: vi.fn(),
99
}))
1010

1111
vi.mock('@socketsecurity/registry/lib/logger', () => ({
@@ -16,9 +16,9 @@ vi.mock('@socketsecurity/registry/lib/logger', () => ({
1616

1717
describe('fetchPurlDeepScore', () => {
1818
it('fetches purl deep score successfully', async () => {
19-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
19+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
2020
const mockQueryApi = vi.mocked(queryApiJson)
21-
const mockSetupSdk = vi.mocked(withSdk)
21+
const mockSetupSdk = vi.mocked(setupSdk)
2222

2323
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
2424

@@ -78,9 +78,9 @@ describe('fetchPurlDeepScore', () => {
7878
})
7979

8080
it('handles SDK setup failure', async () => {
81-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
81+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
8282
const mockQueryApi = vi.mocked(queryApiJson)
83-
const mockSetupSdk = vi.mocked(withSdk)
83+
const mockSetupSdk = vi.mocked(setupSdk)
8484

8585
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
8686

@@ -98,9 +98,9 @@ describe('fetchPurlDeepScore', () => {
9898
})
9999

100100
it('handles API call failure', async () => {
101-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
101+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
102102
const mockQueryApi = vi.mocked(queryApiJson)
103-
const mockSetupSdk = vi.mocked(withSdk)
103+
const mockSetupSdk = vi.mocked(setupSdk)
104104

105105
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
106106

@@ -117,9 +117,9 @@ describe('fetchPurlDeepScore', () => {
117117
})
118118

119119
it('passes custom SDK options', async () => {
120-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
120+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
121121
const mockQueryApi = vi.mocked(queryApiJson)
122-
const mockSetupSdk = vi.mocked(withSdk)
122+
const mockSetupSdk = vi.mocked(setupSdk)
123123

124124
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
125125

@@ -135,9 +135,9 @@ describe('fetchPurlDeepScore', () => {
135135
})
136136

137137
it('handles different purl formats', async () => {
138-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
138+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
139139
const mockQueryApi = vi.mocked(queryApiJson)
140-
const mockSetupSdk = vi.mocked(withSdk)
140+
const mockSetupSdk = vi.mocked(setupSdk)
141141

142142
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
143143

@@ -154,9 +154,9 @@ describe('fetchPurlDeepScore', () => {
154154
})
155155

156156
it('handles low score packages', async () => {
157-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
157+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
158158
const mockQueryApi = vi.mocked(queryApiJson)
159-
const mockSetupSdk = vi.mocked(withSdk)
159+
const mockSetupSdk = vi.mocked(setupSdk)
160160

161161
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
162162

@@ -218,9 +218,9 @@ describe('fetchPurlDeepScore', () => {
218218
})
219219

220220
it('uses null prototype for options', async () => {
221-
const { queryApiJson, withSdk } = await import('../../utils/sdk.mts')
221+
const { queryApiJson, setupSdk } = await import('../../utils/sdk.mts')
222222
const mockQueryApi = vi.mocked(queryApiJson)
223-
const mockSetupSdk = vi.mocked(withSdk)
223+
const mockSetupSdk = vi.mocked(setupSdk)
224224

225225
mockSetupSdk.mockResolvedValue({ ok: true, data: {} as any })
226226

0 commit comments

Comments
 (0)