-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-beautify.mjs
More file actions
57 lines (48 loc) · 1.94 KB
/
test-beautify.mjs
File metadata and controls
57 lines (48 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { GeminiProvider } from './lib/ai/providers/gemini.js';
import { GroqProvider } from './lib/ai/providers/groq.js';
// Mock process.env for testing beautify logic
process.env.GEMINI_API_KEY = 'mock-key';
process.env.GROQ_API_KEY = 'mock-key';
async function testBeautify() {
console.log("--- Testing Beautification Logic ---\n");
const gemini = new GeminiProvider();
const groq = new GroqProvider();
const testCases = [
{
name: "Plain Text",
input: "This is a simple refined prompt.",
expected: "This is a simple refined prompt."
},
{
name: "Markdown JSON Block",
input: "```json\n{\n \"refined_prompt\": \"This is the actual prompt.\"\n}\n```",
expected: "This is the actual prompt."
},
{
name: "Markdown Block No Language",
input: "```\n{\n \"content\": \"Clean this up.\"\n}\n```",
expected: "Clean this up."
},
{
name: "Raw JSON Object",
input: "{\"output\": \"Extracted from output field.\"}",
expected: "Extracted from output field."
},
{
name: "Mixed Markdown and Text",
input: "Here is your prompt:\n```json\n{\"prompt\": \"The Prompt\"}\n```",
expected: "The Prompt"
}
];
for (const test of testCases) {
// Accessing protected/private method for testing
const resultGemini = gemini.beautify(test.input);
const resultGroq = groq.beautify(test.input);
const success = resultGemini === test.expected && resultGroq === test.expected;
console.log(`[${test.name}]`);
console.log(` Input: ${test.input.replace(/\n/g, '\\n')}`);
console.log(` Output: ${resultGemini}`);
console.log(` Result: ${success ? '✅ PASS' : '❌ FAIL (Expected: ' + test.expected + ')'}\n`);
}
}
testBeautify().catch(console.error);