Skip to content

Commit

Permalink
chore: Add test for api-version override (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatKuhr authored Nov 12, 2024
1 parent cc21352 commit e249e42
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,38 @@ describe('Azure OpenAI chat client', () => {
const response = await client.run(prompt);
expect(response.data).toEqual(mockResponse);
});
it('allows a custom api-version', async () => {
const prompt = {
messages: [
{
role: 'user' as const,
content: 'Where is the deepest place on earth located'
}
]
};

const mockResponse =
await parseMockResponse<AzureOpenAiCreateChatCompletionResponse>(
'foundation-models',
'azure-openai-chat-completion-success-response.json'
);

mockInference(
{
data: prompt
},
{
data: mockResponse,
status: 200
},
{ ...chatCompletionEndpoint, apiVersion: 'foo-bar' }
);

const response = await client.run(prompt, {
params: { 'api-version': 'foo-bar' }
});
expect(response.data).toEqual(mockResponse);
});

it('throws on bad request', async () => {
const prompt = { messages: [] };
Expand Down

0 comments on commit e249e42

Please sign in to comment.