Skip to content

Commit 074e8b2

Browse files
authored
copilot review: add test for coverage of no params passed
1 parent f1ca66f commit 074e8b2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

__tests__/inference.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,5 +663,34 @@ describe('inference.ts', () => {
663663
expect(mockCreate.mock.calls[0][0]).toHaveProperty('max_tokens', 100)
664664
expect(mockCreate.mock.calls[0][0]).not.toHaveProperty('max_completion_tokens')
665665
})
666+
667+
it('sends neither token param when both are undefined', async () => {
668+
const requestWithNoTokens = {
669+
...mockRequest,
670+
maxCompletionTokens: undefined,
671+
maxTokens: undefined,
672+
}
673+
674+
const mockResponse = {
675+
choices: [
676+
{
677+
message: {
678+
content: 'No token limit response',
679+
},
680+
},
681+
],
682+
}
683+
684+
mockCreate.mockResolvedValueOnce(mockResponse)
685+
686+
const result = await simpleInference(requestWithNoTokens)
687+
688+
expect(result).toBe('No token limit response')
689+
expect(mockCreate).toHaveBeenCalledTimes(1)
690+
691+
const params = mockCreate.mock.calls[0][0]
692+
expect(params).not.toHaveProperty('max_tokens')
693+
expect(params).not.toHaveProperty('max_completion_tokens')
694+
})
666695
})
667696
})

0 commit comments

Comments
 (0)