forked from memochou1993/gpt-ai-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.test.js
38 lines (35 loc) · 836 Bytes
/
default.test.js
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
import {
afterEach, beforeEach, expect, test,
} from '@jest/globals';
import {
getPrompt, handleEvents, removePrompt, printHistories,
} from '../app/index.js';
import config from '../config/index.js';
import {
createEvents, TIMEOUT, MOCK_USER_01, MOCK_TEXT_OK,
} from './utils.js';
beforeEach(() => {
//
});
afterEach(() => {
removePrompt(MOCK_USER_01);
});
test('DEFAULT', async () => {
const events = [
...createEvents(['嗨!']),
];
let results;
try {
results = await handleEvents(events);
} catch (err) {
console.error(err);
}
if (config.APP_DEBUG) printHistories();
expect(getPrompt(MOCK_USER_01).messages.length).toEqual(5);
const replies = results.map(({ messages }) => messages.map(({ text }) => text));
expect(replies).toEqual(
[
[MOCK_TEXT_OK],
],
);
}, TIMEOUT);