36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
process.env.GEMINI_API_KEY = "dummy_key_for_test";
|
|
const gemini = require('./gemini');
|
|
|
|
async function test() {
|
|
console.log("Testing GeminiService.generateResponse with image parameter...");
|
|
try {
|
|
// Mock the genAI model to avoid actual API call failure if key is missing/invalid for this test environment
|
|
gemini.model = {
|
|
generateContent: async (content) => {
|
|
console.log("Mock generateContent called with:", JSON.stringify(content, null, 2));
|
|
return {
|
|
response: {
|
|
text: () => "Mock response: saw the image!"
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
const response = await gemini.generateResponse(
|
|
"What is this?",
|
|
"Tester",
|
|
{ data: "base64mock", mimeType: "image/jpeg" }
|
|
);
|
|
console.log("Result:", response);
|
|
if (response === "Mock response: saw the image!") {
|
|
console.log("Test PASSED");
|
|
} else {
|
|
console.log("Test FAILED");
|
|
}
|
|
} catch (e) {
|
|
console.error("Test ERROR:", e);
|
|
}
|
|
}
|
|
|
|
test();
|