forked from AIObjectives/talk-to-the-city-reports
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat_v0.test.ts
40 lines (36 loc) · 934 Bytes
/
chat_v0.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
import { describe, it, vi, expect, beforeEach } from 'vitest';
import ChatNode, { chat_node_data } from '$lib/compute/chat_v0';
import deepCopy from 'deep-copy';
import _ from 'lodash';
vi.mock('$lib/gpt', () => ({
openai: vi.fn()
}));
describe('ChatNode class', () => {
let node;
let inputData;
let Cookies;
beforeEach(() => {
node = new ChatNode(deepCopy(chat_node_data));
inputData = {};
Cookies = {
get: vi.fn(),
set: vi.fn()
};
vi.clearAllMocks();
});
it('compute should set output to messages and dirty to false', async () => {
const messages = [{ role: 'user', content: 'Hello' }];
node.data.messages = messages;
const output = await node.compute(
inputData,
'context',
console.log,
console.error,
console.log,
'slug',
Cookies
);
expect(output).toEqual(messages);
expect(node.data.dirty).toBe(false);
});
});