Skip to content

Commit

Permalink
Simplest test for getFileSuggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
tpaulshippy committed Jun 22, 2024
1 parent f1d3635 commit d0b3eef
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/helpers/llm.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCompletion, getOpenAi, getSimpleCompletion } from './llm';
import { getCompletion, getOpenAi, getSimpleCompletion, getFileSuggestion } from './llm';
import { KnownError } from './error';
import { expect, describe, it, vi } from 'vitest';
import OpenAI from 'openai';
Expand Down Expand Up @@ -177,3 +177,23 @@ describe('getCompletion', () => {
expect(stdErrWriteMock).toHaveBeenCalledWith(gray('World'));
});
});


describe('getFileSuggestion', () => {
it('should return a valid file suggestion based on input', async () => {
mocks.getConfig.mockResolvedValue({
...defaultConfig,
MODEL: 'gpt-4o',
});
mocks.create.mockResolvedValueOnce({
choices: [{ message: { tool_calls: [{function: { arguments: "{ \"filePath\": \"/src/add.test.ts\"}"}}] } }],
});
const prompt = 'a function that adds numbers';
const fileString = 'src/add.ts\nsrc/subtract.ts\nsrc/multiply.ts';
const expectedResult = 'src/add.test.ts';
const result = await getFileSuggestion(prompt, fileString);
expect(result).to.equal(expectedResult);

});

});

0 comments on commit d0b3eef

Please sign in to comment.