-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchatbot.test.ts
More file actions
44 lines (37 loc) · 1.53 KB
/
chatbot.test.ts
File metadata and controls
44 lines (37 loc) · 1.53 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
import { describe, it, expect, beforeAll } from 'vitest';
import { ComponentRegistry } from '@object-ui/core';
describe('Chatbot Component', () => {
// Import all renderers to register them
beforeAll(async () => {
await import('./index');
});
it('should be registered in ComponentRegistry', () => {
const chatbotRenderer = ComponentRegistry.get('chatbot');
expect(chatbotRenderer).toBeDefined();
});
it('should have proper metadata', () => {
const config = ComponentRegistry.getConfig('chatbot');
expect(config).toBeDefined();
expect(config?.label).toBe('Chatbot');
expect(config?.inputs).toBeDefined();
expect(config?.defaultProps).toBeDefined();
});
it('should have expected inputs', () => {
const config = ComponentRegistry.getConfig('chatbot');
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
expect(inputNames).toContain('messages');
expect(inputNames).toContain('placeholder');
expect(inputNames).toContain('showTimestamp');
expect(inputNames).toContain('userAvatarUrl');
expect(inputNames).toContain('assistantAvatarUrl');
});
it('should have sensible default props', () => {
const config = ComponentRegistry.getConfig('chatbot');
const defaults = config?.defaultProps;
expect(defaults).toBeDefined();
expect(defaults?.placeholder).toBe('Type your message...');
expect(defaults?.showTimestamp).toBe(false);
expect(defaults?.messages).toBeDefined();
expect(Array.isArray(defaults?.messages)).toBe(true);
});
});