restored normally operating app.
This commit is contained in:
31
app/lib/__tests__/conversation.spec.tsx
Normal file
31
app/lib/__tests__/conversation.spec.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
// conversation.test.ts
|
||||
|
||||
import { Translator } from '@/app/i18n/api';
|
||||
import { Conversation, Message, Speaker } from '@/app/lib/conversation';
|
||||
import { describe, beforeEach, it, expect, test } from '@jest/globals';
|
||||
|
||||
describe('Conversation', () => {
|
||||
let conversation: Conversation;
|
||||
|
||||
beforeEach(() => {
|
||||
const translator = new Translator("en", "es");
|
||||
const s1: Speaker = { language: "en", id: "host" };
|
||||
const s2: Speaker = { id: "guest", language: "es" }
|
||||
conversation = new Conversation(translator, s1, s2);
|
||||
});
|
||||
|
||||
it('should add a message to the conversation', () => {
|
||||
conversation.addMessage({ id: "host", language: "en" }, "Hello");
|
||||
expect(conversation.length).toBe(1);
|
||||
expect(conversation[0].speaker.id).toEqual("host");
|
||||
expect(conversation[0].text).toEqual("Hello");
|
||||
});
|
||||
|
||||
it('should translate the last message in the conversation', async () => {
|
||||
|
||||
conversation.addMessage({ id: "host", language: "en" }, "Hello");
|
||||
|
||||
await conversation.translateLast();
|
||||
expect(conversation[conversation.length - 1].translation).toEqual("Hola");
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user