add ollama files. Fix unit tests (finally). TODO: handle static file downloading and screens.
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
// conversation.test.ts
|
||||
|
||||
import { Translator } from '@/app/i18n/api';
|
||||
import { LanguageServer, Translator } from '@/app/i18n/api';
|
||||
import { Conversation, Message, Speaker } from '@/app/lib/conversation';
|
||||
import { LIBRETRANSLATE_BASE_URL } from '@/constants/api';
|
||||
import { describe, beforeEach, it, expect, test } from '@jest/globals';
|
||||
|
||||
describe('Conversation', () => {
|
||||
let conversation: Conversation;
|
||||
|
||||
beforeEach(() => {
|
||||
const translator = new Translator("en", "es");
|
||||
const translator = new Translator("en", "es", new LanguageServer(LIBRETRANSLATE_BASE_URL));
|
||||
const s1: Speaker = { language: "en", id: "host" };
|
||||
const s2: Speaker = { id: "guest", language: "es" }
|
||||
conversation = new Conversation(translator, s1, s2);
|
||||
|
@ -20,6 +20,7 @@ describe('Settings', () => {
|
||||
describe('setHostLanguage', () => {
|
||||
it('should set the host language in the database', async () => {
|
||||
const value = 'en';
|
||||
await settings.db.runAsync("REPLACE INTO settings (host_language) VALUES (?)", "en");
|
||||
await settings.setHostLanguage(value);
|
||||
|
||||
const result = await settings.getHostLanguage();
|
||||
@ -30,10 +31,7 @@ describe('Settings', () => {
|
||||
describe('getHostLanguage', () => {
|
||||
it('should return the host language from the database', async () => {
|
||||
const value = 'fr';
|
||||
await settings.db.executeSql(
|
||||
`INSERT INTO settings (host_language) VALUES (?)`,
|
||||
[value]
|
||||
);
|
||||
await settings.setHostLanguage(value);
|
||||
|
||||
const result = await settings.getHostLanguage();
|
||||
expect(result).toEqual(value);
|
||||
@ -41,14 +39,14 @@ describe('Settings', () => {
|
||||
|
||||
it('should return null if the host language is not set', async () => {
|
||||
const result = await settings.getHostLanguage();
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('setLibretranslateBaseUrl', () => {
|
||||
it('should set the LibreTranslate base URL in the database', async () => {
|
||||
const value = 'https://example.com';
|
||||
await settings.setLibetransalteBaseUrl(value);
|
||||
await settings.setLibretranslateBaseUrl(value);
|
||||
|
||||
const result = await settings.getLibretranslateBaseUrl();
|
||||
expect(result).toEqual(value);
|
||||
@ -56,20 +54,9 @@ describe('Settings', () => {
|
||||
});
|
||||
|
||||
describe('getLibretranslateBaseUrl', () => {
|
||||
it('should return the LibreTranslate base URL from the database', async () => {
|
||||
const value = 'https://another-example.com';
|
||||
await settings.db.executeSql(
|
||||
`INSERT INTO settings (libretranslate_base_url) VALUES (?)`,
|
||||
[value]
|
||||
);
|
||||
|
||||
const result = await settings.getLibretranslateBaseUrl();
|
||||
expect(result).toEqual(value);
|
||||
});
|
||||
|
||||
it('should return null if the LibreTranslate base URL is not set', async () => {
|
||||
const result = await settings.getLibretranslateBaseUrl();
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user