mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-04 10:52:13 +02:00
fix(cli): clean up connection commands (#62)
* fix(cli): clean up connection commands * test(cli): update connection smoke coverage * Fix setup output formatting * fix notion setup picker exit
This commit is contained in:
parent
4973ca562f
commit
e1e9c4af91
33 changed files with 1096 additions and 5342 deletions
|
|
@ -17,9 +17,11 @@ function makeTracker(ctrlCValues: boolean[]): SetupInterruptTracker {
|
|||
|
||||
describe('setup interrupt confirmation', () => {
|
||||
const originalIsTTY = process.stdin.isTTY;
|
||||
const originalRef = process.stdin.ref;
|
||||
|
||||
afterEach(() => {
|
||||
Object.defineProperty(process.stdin, 'isTTY', { configurable: true, value: originalIsTTY });
|
||||
Object.defineProperty(process.stdin, 'ref', { configurable: true, value: originalRef });
|
||||
});
|
||||
|
||||
it('fails before opening a prompt when interactive setup has no tty', async () => {
|
||||
|
|
@ -33,6 +35,26 @@ describe('setup interrupt confirmation', () => {
|
|||
expect(prompt).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('refs stdin before opening a real interactive prompt', async () => {
|
||||
const calls: string[] = [];
|
||||
Object.defineProperty(process.stdin, 'isTTY', { configurable: true, value: true });
|
||||
Object.defineProperty(process.stdin, 'ref', {
|
||||
configurable: true,
|
||||
value: vi.fn(() => {
|
||||
calls.push('ref');
|
||||
return process.stdin;
|
||||
}),
|
||||
});
|
||||
const prompt = vi.fn(async () => {
|
||||
calls.push('prompt');
|
||||
return 'continued';
|
||||
});
|
||||
|
||||
await expect(withSetupInterruptConfirmation(prompt)).resolves.toBe('continued');
|
||||
|
||||
expect(calls).toEqual(['ref', 'prompt']);
|
||||
});
|
||||
|
||||
it('asks before exiting on Ctrl+C and reruns the active prompt when declined', async () => {
|
||||
const prompt = vi.fn(async () => (prompt.mock.calls.length === 1 ? CANCEL : 'continued'));
|
||||
const confirmExit = vi.fn(async () => false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue