Skip to content

Commit cbab591

Browse files
committed
test(coverage): output-config-auto array data branch for defaultOrg/enforcedOrgs
1 parent 22b5b90 commit cbab591

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

packages/cli/test/unit/commands/config/output-config-auto.test.mts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,39 @@ describe('output-config-auto', () => {
300300
const logs = mockLogger.log.mock.calls.map(c => c[0]).join('\n')
301301
expect(logs).toContain('No changes made')
302302
})
303+
304+
it('handles array data for defaultOrg by mapping each item to a choice', async () => {
305+
mockSelect.mockResolvedValue('org-a')
306+
mockUpdateConfigValue.mockReturnValue({ ok: true })
307+
308+
const result: CResult<string[]> = {
309+
ok: true,
310+
data: ['org-a', 'org-b', 'org-c'],
311+
}
312+
313+
await outputConfigAuto('defaultOrg', result as any, 'text')
314+
315+
const selectCallArgs = mockSelect.mock.calls[0]![0] as {
316+
choices: Array<{ value: string }>
317+
}
318+
expect(selectCallArgs.choices.length).toBeGreaterThanOrEqual(3)
319+
})
320+
321+
it('handles array data for enforcedOrgs by mapping each item to a choice', async () => {
322+
mockSelect.mockResolvedValue('')
323+
324+
const result: CResult<string[]> = {
325+
ok: true,
326+
data: ['org-a', 'org-b'],
327+
}
328+
329+
await outputConfigAuto('enforcedOrgs', result as any, 'text')
330+
331+
const selectCallArgs = mockSelect.mock.calls[0]![0] as {
332+
choices: Array<{ value: string }>
333+
}
334+
expect(selectCallArgs.choices.length).toBeGreaterThanOrEqual(2)
335+
})
303336
})
304337
})
305338
})

0 commit comments

Comments
 (0)