import { promptForAuthType, REFRESH_TOKEN_AUTH_CHOICE, CREDENTIAL_PROCESS_AUTH_CHOICE, } from './promptForAuthType'; import { getStdErrPrompt } from './getStdErrPrompt'; jest.mock('./getStdErrPrompt'); describe('promptForAuthType', () => { let capturedPrompt: any; beforeEach(() => { (getStdErrPrompt as jest.Mock).mockReturnValue((prompts: any[]) => { capturedPrompt = prompts[0]; return Promise.resolve({ authType: REFRESH_TOKEN_AUTH_CHOICE }); }); }); afterEach(() => { jest.resetAllMocks(); }); it('offers exactly refresh-token and credential-process', async () => { await promptForAuthType(); const values = capturedPrompt.choices.map((c: any) => c.value); expect(values).toEqual([ REFRESH_TOKEN_AUTH_CHOICE, CREDENTIAL_PROCESS_AUTH_CHOICE, ]); }); it('does not offer password or always-ask', async () => { await promptForAuthType(); const values = capturedPrompt.choices.map((c: any) => c.value); expect(values).not.toContain('password'); expect(values).not.toContain('always-ask'); }); });