mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -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
|
||||
let sigIntHandler: (() => void) | undefined;
|
||||
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 processOnSpy = vi.spyOn(process, 'on');
|
||||
const processRemoveListenerSpy = vi.spyOn(process, 'removeListener');
|
||||
|
||||
const clientPromise = getOauthClient(
|
||||
@@ -1154,6 +1140,11 @@ describe('oauth2', () => {
|
||||
// Wait a tick to ensure the SIGINT handler is registered
|
||||
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();
|
||||
|
||||
// Trigger SIGINT
|
||||
@@ -1196,15 +1187,7 @@ describe('oauth2', () => {
|
||||
);
|
||||
|
||||
// Spy on process.stdin.on
|
||||
let dataHandler: ((data: Buffer) => void) | undefined;
|
||||
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 stdinOnSpy = vi.spyOn(process.stdin, 'on');
|
||||
const stdinRemoveListenerSpy = vi.spyOn(
|
||||
process.stdin,
|
||||
'removeListener',
|
||||
@@ -1217,6 +1200,13 @@ describe('oauth2', () => {
|
||||
|
||||
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();
|
||||
|
||||
// Trigger Ctrl+C
|
||||
|
||||
Reference in New Issue
Block a user