mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Fix failing unit tests (#15940)
This commit is contained in:
committed by
GitHub
parent
ed8bad8c26
commit
fd7b6bf40a
@@ -1129,21 +1129,7 @@ describe('oauth2', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Spy on process.on to capture the SIGINT handler
|
// Spy on process.on to capture the SIGINT handler
|
||||||
let sigIntHandler: (() => void) | undefined;
|
const processOnSpy = vi.spyOn(process, 'on');
|
||||||
const originalOn = process.on;
|
|
||||||
const processOnSpy = vi
|
|
||||||
.spyOn(process, 'on')
|
|
||||||
.mockImplementation(
|
|
||||||
(
|
|
||||||
event: string | symbol,
|
|
||||||
listener: (...args: unknown[]) => void,
|
|
||||||
) => {
|
|
||||||
if (event === 'SIGINT') {
|
|
||||||
sigIntHandler = listener as () => void;
|
|
||||||
}
|
|
||||||
return originalOn.call(process, event, listener);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
const processRemoveListenerSpy = vi.spyOn(process, 'removeListener');
|
const processRemoveListenerSpy = vi.spyOn(process, 'removeListener');
|
||||||
|
|
||||||
const clientPromise = getOauthClient(
|
const clientPromise = getOauthClient(
|
||||||
@@ -1154,6 +1140,11 @@ describe('oauth2', () => {
|
|||||||
// Wait a tick to ensure the SIGINT handler is registered
|
// Wait a tick to ensure the SIGINT handler is registered
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
|
const sigintCall = processOnSpy.mock.calls.find(
|
||||||
|
(call) => call[0] === 'SIGINT',
|
||||||
|
);
|
||||||
|
const sigIntHandler = sigintCall?.[1] as (() => void) | undefined;
|
||||||
|
|
||||||
expect(sigIntHandler).toBeDefined();
|
expect(sigIntHandler).toBeDefined();
|
||||||
|
|
||||||
// Trigger SIGINT
|
// Trigger SIGINT
|
||||||
@@ -1196,15 +1187,7 @@ describe('oauth2', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Spy on process.stdin.on
|
// Spy on process.stdin.on
|
||||||
let dataHandler: ((data: Buffer) => void) | undefined;
|
const stdinOnSpy = vi.spyOn(process.stdin, 'on');
|
||||||
const stdinOnSpy = vi
|
|
||||||
.spyOn(process.stdin, 'on')
|
|
||||||
.mockImplementation((event: string | symbol, listener) => {
|
|
||||||
if (event === 'data') {
|
|
||||||
dataHandler = listener as (data: Buffer) => void;
|
|
||||||
}
|
|
||||||
return process.stdin;
|
|
||||||
});
|
|
||||||
const stdinRemoveListenerSpy = vi.spyOn(
|
const stdinRemoveListenerSpy = vi.spyOn(
|
||||||
process.stdin,
|
process.stdin,
|
||||||
'removeListener',
|
'removeListener',
|
||||||
@@ -1217,6 +1200,13 @@ describe('oauth2', () => {
|
|||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
||||||
|
const dataCall = stdinOnSpy.mock.calls.find(
|
||||||
|
(call: [string, ...unknown[]]) => call[0] === 'data',
|
||||||
|
);
|
||||||
|
const dataHandler = dataCall?.[1] as
|
||||||
|
| ((data: Buffer) => void)
|
||||||
|
| undefined;
|
||||||
|
|
||||||
expect(dataHandler).toBeDefined();
|
expect(dataHandler).toBeDefined();
|
||||||
|
|
||||||
// Trigger Ctrl+C
|
// Trigger Ctrl+C
|
||||||
|
|||||||
Reference in New Issue
Block a user