-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathassistant.test.ts
94 lines (82 loc) · 2.84 KB
/
assistant.test.ts
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { AbstractAssistant } from '../../src/llm/assistant';
import { ProcessImageMessageProps } from '../../src/types';
import { RegisterFunctionCallingProps } from '../../src/types';
describe('AbstractAssistant', () => {
let assistant: AbstractAssistant;
beforeEach(() => {
assistant = new class extends AbstractAssistant {}();
});
test('getInstance should throw an error', async () => {
await expect(AbstractAssistant.getInstance()).rejects.toThrow(
'Method not implemented.'
);
});
test('configure should throw an error', () => {
expect(() =>
AbstractAssistant.configure({
model: 'test',
apiKey: 'key',
})
).toThrow('Method not implemented.');
});
test('close should throw an error', async () => {
await expect(assistant.close()).rejects.toThrow('Method not implemented.');
});
test('stop should throw an error', () => {
expect(() => assistant.stop()).toThrow('Method not implemented.');
});
test('restart should throw an error', () => {
expect(() => assistant.restart()).toThrow('Method not implemented.');
});
test('processImageMessage should throw an error', async () => {
const mockProps: ProcessImageMessageProps = {
imageMessage: 'base64_encoded_image_string',
textMessage: 'Sample text message',
streamMessageCallback: jest.fn(),
};
await expect(assistant.processImageMessage(mockProps)).rejects.toThrow(
'Method not implemented.'
);
});
test('translateVoiceToText should throw an error', async () => {
await expect(assistant.translateVoiceToText(new Blob())).rejects.toThrow(
'Method not implemented.'
);
});
test('processTextMessage should throw an error', async () => {
const mockProps = {
textMessage: 'Sample text',
streamMessageCallback: jest.fn(),
};
await expect(assistant.processTextMessage(mockProps)).rejects.toThrow(
'Method not implemented.'
);
});
test('registerFunctionCalling should throw an error', () => {
const mockProps: RegisterFunctionCallingProps = {
name: 'testFunction',
description: 'A test function',
properties: {},
required: [],
callbackFunction: () => ({
name: 'name',
type: 'type',
result: 'result',
}),
};
expect(() => AbstractAssistant.registerFunctionCalling(mockProps)).toThrow(
'Method not implemented.'
);
});
test('audioToText should throw an error', async () => {
const mockAudioBlob = new Blob([], { type: 'audio/wav' });
await expect(
assistant.audioToText({ audioBlob: mockAudioBlob })
).rejects.toThrow('Method not implemented.');
});
test('addAdditionalContext should throw an error', async () => {
await expect(
assistant.addAdditionalContext({ context: 'test' })
).rejects.toThrow('Method not implemented.');
});
});