-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeminiService.test.ts
More file actions
65 lines (58 loc) · 1.73 KB
/
geminiService.test.ts
File metadata and controls
65 lines (58 loc) · 1.73 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
58
59
60
61
62
63
64
65
import { describe, it, expect, vi } from 'vitest';
import { analyzeAsset, generateCaseStudy } from '../services/geminiService';
import { Asset } from '../types';
// Mock the Gemini API
vi.mock('@google/genai', () => ({
GoogleGenAI: vi.fn(() => ({
models: {
generateContent: vi.fn().mockResolvedValue({
text: JSON.stringify({
topic: 'auth',
type: 'wireframe',
context: 'mobile',
variant: 'dark',
version: 'v2'
})
})
}
})),
Type: {
OBJECT: 'object',
STRING: 'string',
ARRAY: 'array'
}
}));
describe('geminiService', () => {
describe('analyzeAsset', () => {
it('should analyze a file and return metadata', async () => {
const file = new File(['test content'], 'test.png', { type: 'image/png' });
const result = await analyzeAsset(file, 'image/png', false);
expect(result).toHaveProperty('topic');
expect(result).toHaveProperty('type');
expect(result).toHaveProperty('context');
expect(result).toHaveProperty('variant');
expect(result).toHaveProperty('version');
});
});
describe('generateCaseStudy', () => {
it('should generate a case study from assets', async () => {
const assets: Asset[] = [
{
id: '1',
originalName: 'wireframe.png',
aiName: 'auth-wireframe-mobile-dark-v2.png',
type: 'wireframe',
topic: 'auth',
context: 'mobile',
variant: 'dark',
version: 'v2',
fileType: 'png',
url: 'blob:test',
size: 1024
}
];
const result = await generateCaseStudy(assets, 'Test context', false);
expect(result).toBeDefined();
});
});
});