Skip to content

Commit d9d3668

Browse files
committed
Update scanning and organization tests for options pattern
Update test calls to use new options object pattern instead of positional parameters for: - createDependenciesSnapshot - createOrgFullScan - streamOrgFullScan
1 parent 0a0b93e commit d9d3668

2 files changed

Lines changed: 26 additions & 31 deletions

File tree

test/socket-sdk-organization.test.mts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ describe('SocketSdk - Organization Management', () => {
265265

266266
// Simply verify the API call succeeds when streaming to stdout
267267
// The actual streaming happens asynchronously, so we just verify the method works
268-
const res = await client.streamOrgFullScan('test-org', 'scan-456', true)
268+
const res = await client.streamOrgFullScan('test-org', 'scan-456', {
269+
output: true,
270+
})
269271
expect(res.success).toBe(true)
270272
})
271273

@@ -279,11 +281,9 @@ describe('SocketSdk - Organization Management', () => {
279281
const tempFile = path.join(tmpdir(), 'test-scan.json')
280282

281283
// Since we can't easily mock createWriteStream in ESM, we'll just verify the request happens
282-
const res = await client.streamOrgFullScan(
283-
'test-org',
284-
'scan-789',
285-
tempFile,
286-
)
284+
const res = await client.streamOrgFullScan('test-org', 'scan-789', {
285+
output: tempFile,
286+
})
287287

288288
expect(res.success).toBe(true)
289289
})
@@ -302,11 +302,9 @@ describe('SocketSdk - Organization Management', () => {
302302
return true
303303
}
304304

305-
const res = await client.streamOrgFullScan(
306-
'test-org',
307-
'scan-no-stream',
308-
false,
309-
)
305+
const res = await client.streamOrgFullScan('test-org', 'scan-no-stream', {
306+
output: false,
307+
})
310308

311309
process.stdout.write = originalWrite
312310
expect(res.success).toBe(true)
@@ -374,11 +372,9 @@ describe('SocketSdk - Organization Management', () => {
374372
})
375373

376374
const client = new SocketSdk('test-token')
377-
const res = await client.createOrgFullScan(
378-
'test-org',
379-
[packageJsonPath],
380-
tempDir,
381-
)
375+
const res = await client.createOrgFullScan('test-org', [packageJsonPath], {
376+
pathsRelativeTo: tempDir,
377+
})
382378

383379
expect(res.success).toBe(true)
384380
if (res.success) {

test/socket-sdk-scanning.test.mts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ describe('SocketSdk - Scanning APIs', () => {
232232
})
233233

234234
const client = new SocketSdk('test-token')
235-
const res = await client.createDependenciesSnapshot(
236-
[packageJsonPath],
237-
tempDir,
238-
)
235+
const res = await client.createDependenciesSnapshot([packageJsonPath], {
236+
pathsRelativeTo: tempDir,
237+
})
239238

240239
expect(res.success).toBe(true)
241240
if (res.success) {
@@ -253,11 +252,10 @@ describe('SocketSdk - Scanning APIs', () => {
253252
})
254253

255254
const client = new SocketSdk('test-token')
256-
const res = await client.createDependenciesSnapshot(
257-
[packageJsonPath],
258-
tempDir,
259-
{ branch: 'main', commit: 'abc123' },
260-
)
255+
const res = await client.createDependenciesSnapshot([packageJsonPath], {
256+
pathsRelativeTo: tempDir,
257+
queryParams: { branch: 'main', commit: 'abc123' },
258+
})
261259

262260
expect(res.success).toBe(true)
263261
if (res.success) {
@@ -276,10 +274,9 @@ describe('SocketSdk - Scanning APIs', () => {
276274
})
277275

278276
const client = new SocketSdk('test-token')
279-
const res = await client.createDependenciesSnapshot(
280-
[packageJsonPath],
281-
tempDir,
282-
)
277+
const res = await client.createDependenciesSnapshot([packageJsonPath], {
278+
pathsRelativeTo: tempDir,
279+
})
283280

284281
expect(res.success).toBe(false)
285282
expect(res.status).toBe(413)
@@ -315,7 +312,9 @@ describe('SocketSdk - Scanning APIs', () => {
315312
})
316313

317314
const client = new SocketSdk('test-token')
318-
const res = await client.createDependenciesSnapshot([largePath], tempDir)
315+
const res = await client.createDependenciesSnapshot([largePath], {
316+
pathsRelativeTo: tempDir,
317+
})
319318

320319
expect(res.success).toBe(true)
321320
if (res.success) {
@@ -350,7 +349,7 @@ describe('SocketSdk - Scanning APIs', () => {
350349
const res = await client.createOrgFullScan(
351350
'test-org',
352351
[packageJsonPath, readmePath, yarnLockPath],
353-
tempDir,
352+
{ pathsRelativeTo: tempDir },
354353
)
355354

356355
expect(res.success).toBe(true)

0 commit comments

Comments
 (0)