Skip to content

Commit 9a13501

Browse files
committed
test(scan): add workspace flag test coverage
1 parent 0b61fc4 commit 9a13501

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

packages/cli/test/unit/commands/scan/cmd-scan-create.test.mts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,54 @@ describe('cmd-scan-create', () => {
582582
)
583583
})
584584

585+
it('should use socket.json defaults for workspace', async () => {
586+
mockReadOrDefaultSocketJsonUp.mockResolvedValueOnce({
587+
defaults: {
588+
scan: {
589+
create: {
590+
workspace: 'my-workspace',
591+
},
592+
},
593+
},
594+
})
595+
mockHasDefaultApiToken.mockReturnValueOnce(true)
596+
597+
await cmdScanCreate.run(
598+
['--org', 'test-org', '.', '--no-interactive'],
599+
importMeta,
600+
context,
601+
)
602+
603+
expect(mockHandleCreateNewScan).toHaveBeenCalledWith(
604+
expect.objectContaining({
605+
workspace: 'my-workspace',
606+
}),
607+
)
608+
})
609+
610+
it('should pass --workspace flag to handleCreateNewScan', async () => {
611+
mockHasDefaultApiToken.mockReturnValueOnce(true)
612+
613+
await cmdScanCreate.run(
614+
[
615+
'--org',
616+
'test-org',
617+
'--workspace',
618+
'cli-workspace',
619+
'.',
620+
'--no-interactive',
621+
],
622+
importMeta,
623+
context,
624+
)
625+
626+
expect(mockHandleCreateNewScan).toHaveBeenCalledWith(
627+
expect.objectContaining({
628+
workspace: 'cli-workspace',
629+
}),
630+
)
631+
})
632+
585633
it('should override socket.json defaults with CLI flags', async () => {
586634
mockReadOrDefaultSocketJsonUp.mockResolvedValueOnce({
587635
defaults: {

0 commit comments

Comments
 (0)