mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 07:10:34 -07:00
Fixes 'input.on' is not a function error in Gemini CLI (#19691)
This commit is contained in:
committed by
GitHub
parent
cdf157e52a
commit
7cf4c05c66
@@ -408,6 +408,48 @@ describe('CodeAssistServer', () => {
|
||||
expect(results[1].candidates?.[0].content?.parts?.[0].text).toBe(' World');
|
||||
});
|
||||
|
||||
it('should handle Web ReadableStream in generateContentStream', async () => {
|
||||
const { server, mockRequest } = createTestServer();
|
||||
|
||||
// Create a mock Web ReadableStream
|
||||
const mockWebStream = new ReadableStream({
|
||||
start(controller) {
|
||||
const mockResponseData = {
|
||||
response: {
|
||||
candidates: [{ content: { parts: [{ text: 'Hello Web' }] } }],
|
||||
},
|
||||
};
|
||||
controller.enqueue(
|
||||
new TextEncoder().encode(
|
||||
'data: ' + JSON.stringify(mockResponseData) + '\n\n',
|
||||
),
|
||||
);
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
|
||||
mockRequest.mockResolvedValue({ data: mockWebStream });
|
||||
|
||||
const stream = await server.generateContentStream(
|
||||
{
|
||||
model: 'test-model',
|
||||
contents: [{ role: 'user', parts: [{ text: 'request' }] }],
|
||||
},
|
||||
'user-prompt-id',
|
||||
LlmRole.MAIN,
|
||||
);
|
||||
|
||||
const results = [];
|
||||
for await (const res of stream) {
|
||||
results.push(res);
|
||||
}
|
||||
|
||||
expect(results).toHaveLength(1);
|
||||
expect(results[0].candidates?.[0].content?.parts?.[0].text).toBe(
|
||||
'Hello Web',
|
||||
);
|
||||
});
|
||||
|
||||
it('should ignore malformed SSE data', async () => {
|
||||
const { server, mockRequest } = createTestServer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user