@@ -19,11 +19,11 @@ describe("GroqHandler", () => {
1919 beforeEach ( ( ) => {
2020 jest . clearAllMocks ( )
2121 mockCreate = ( OpenAI as unknown as jest . Mock ) ( ) . chat . completions . create
22- handler = new GroqHandler ( { } )
22+ handler = new GroqHandler ( { groqApiKey : "test-groq-api-key" } )
2323 } )
2424
2525 test ( "should use the correct Groq base URL" , ( ) => {
26- new GroqHandler ( { } )
26+ new GroqHandler ( { groqApiKey : "test-groq-api-key" } )
2727 expect ( OpenAI ) . toHaveBeenCalledWith ( expect . objectContaining ( { baseURL : "https://api.groq.com/openai/v1" } ) )
2828 } )
2929
@@ -35,17 +35,16 @@ describe("GroqHandler", () => {
3535
3636 test ( "should return default model when no model is specified" , ( ) => {
3737 const model = handler . getModel ( )
38- expect ( model . id ) . toBe ( groqDefaultModelId ) // Use groqDefaultModelId
39- expect ( model . info ) . toEqual ( groqModels [ groqDefaultModelId ] ) // Use groqModels
38+ expect ( model . id ) . toBe ( groqDefaultModelId )
39+ expect ( model . info ) . toEqual ( groqModels [ groqDefaultModelId ] )
4040 } )
4141
4242 test ( "should return specified model when valid model is provided" , ( ) => {
43- const testModelId : GroqModelId = "llama-3.3-70b-versatile" // Use a valid Groq model ID and type
44- const handlerWithModel = new GroqHandler ( { apiModelId : testModelId } ) // Instantiate GroqHandler
43+ const testModelId : GroqModelId = "llama-3.3-70b-versatile"
44+ const handlerWithModel = new GroqHandler ( { apiModelId : testModelId , groqApiKey : "test-groq-api-key" } )
4545 const model = handlerWithModel . getModel ( )
46-
4746 expect ( model . id ) . toBe ( testModelId )
48- expect ( model . info ) . toEqual ( groqModels [ testModelId ] ) // Use groqModels
47+ expect ( model . info ) . toEqual ( groqModels [ testModelId ] )
4948 } )
5049
5150 test ( "completePrompt method should return text from Groq API" , async ( ) => {
@@ -110,7 +109,7 @@ describe("GroqHandler", () => {
110109 test ( "createMessage should pass correct parameters to Groq client" , async ( ) => {
111110 const modelId : GroqModelId = "llama-3.1-8b-instant"
112111 const modelInfo = groqModels [ modelId ]
113- const handlerWithModel = new GroqHandler ( { apiModelId : modelId } )
112+ const handlerWithModel = new GroqHandler ( { apiModelId : modelId , groqApiKey : "test-groq-api-key" } )
114113
115114 mockCreate . mockImplementationOnce ( ( ) => {
116115 return {
0 commit comments