style: format source and test files

This commit is contained in:
Tam Nhu Tran committed 2026-02-17 17:03:11 +07:00
1 parent f451f4e421
commit 539afea737
34 files changed
+486 -295

No files matched your search

+25 -29
View File
@@ -141,39 +141,35 @@ describe('startDaemon', () => {
expect(result.error).toContain('Invalid port');
});
it(
'starts and stops daemon successfully',
async () => {
const port = 10000 + Math.floor(Math.random() * 50000);
const result = await startDaemon({ port, ghost_mode: true });
expect(result.success).toBe(true);
expect(result.pid).toBeDefined();
it('starts and stops daemon successfully', async () => {
const port = 10000 + Math.floor(Math.random() * 50000);
const result = await startDaemon({ port, ghost_mode: true });
expect(result.success).toBe(true);
expect(result.pid).toBeDefined();
// Verify health
const running = await isDaemonRunning(port);
expect(running).toBe(true);
// Verify health
const running = await isDaemonRunning(port);
expect(running).toBe(true);
// Verify chat endpoint exists (requires auth, should not be 404)
const chatResponse = await fetch(`http://127.0.0.1:${port}/v1/chat/completions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-4.1',
messages: [{ role: 'user', content: 'hello' }],
}),
});
expect(chatResponse.status).toBe(401);
// Verify chat endpoint exists (requires auth, should not be 404)
const chatResponse = await fetch(`http://127.0.0.1:${port}/v1/chat/completions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: 'gpt-4.1',
messages: [{ role: 'user', content: 'hello' }],
}),
});
expect(chatResponse.status).toBe(401);
// Stop
const stopResult = await stopDaemon();
expect(stopResult.success).toBe(true);
// Stop
const stopResult = await stopDaemon();
expect(stopResult.success).toBe(true);
// Verify stopped
const stillRunning = await isDaemonRunning(port);
expect(stillRunning).toBe(false);
},
35000
);
// Verify stopped
const stillRunning = await isDaemonRunning(port);
expect(stillRunning).toBe(false);
}, 35000);
});
describe('isDaemonRunning', () => {
+16 -4
View File
@@ -300,7 +300,9 @@ describe('Message Translation', () => {
expect(result.messages).toHaveLength(1);
expect(result.messages[0].role).toBe('user');
expect(result.messages[0].content).toBe('[System Instructions]\nSystem instruction part 1 part 2');
expect(result.messages[0].content).toBe(
'[System Instructions]\nSystem instruction part 1 part 2'
);
});
});
});
@@ -332,7 +334,12 @@ describe('Request Encoding', () => {
},
];
const result = generateCursorBody([{ role: 'user', content: 'What is the weather?' }], 'gpt-4', tools, null);
const result = generateCursorBody(
[{ role: 'user', content: 'What is the weather?' }],
'gpt-4',
tools,
null
);
expect(result).toBeInstanceOf(Uint8Array);
expect(result.length).toBeGreaterThan(0);
@@ -358,7 +365,9 @@ describe('Request Encoding', () => {
const executor = new CursorExecutor();
// Frame header says payload is 100 bytes but only 5 bytes follow
const truncatedFrame = Buffer.from([0x00, 0x00, 0x00, 0x00, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05]);
const truncatedFrame = Buffer.from([
0x00, 0x00, 0x00, 0x00, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05,
]);
const result = executor.transformProtobufToJSON(truncatedFrame, 'gpt-4', {
messages: [],
@@ -644,7 +653,10 @@ describe('CursorExecutor', () => {
];
// buildCursorRequest expects (model, body, stream, credentials)
buildCursorRequest('test-model', { messages }, false, { machineId: '12345', accessToken: 'test' });
buildCursorRequest('test-model', { messages }, false, {
machineId: '12345',
accessToken: 'test',
});
// Should have logged warning
const hasWarning = consoleSpy.some((log) => log.includes('Unknown message role'));