import { Settings } from '@/app/lib/settings'; import { getDb, migrateDb } from '@/app/lib/db'; import { SQLiteDatabase } from 'expo-sqlite'; describe('Settings', () => { let settings: Settings; let db: SQLiteDatabase; beforeEach(async () => { db = await getDb("development"); settings = new Settings(db); }); afterEach(async () => { await migrateDb("development"); }); it('should set the host language in the database', async () => { const value = 'en'; await settings.setHostLanguage(value); const result = await settings.getHostLanguage(); expect(result).toEqual(value); }); describe('getHostLanguage', () => { it('should return the host language from the database', async () => { const value = 'fr'; await settings.setHostLanguage(value); const result = await settings.getHostLanguage(); expect(result).toEqual(value); }); it('should return null if the host language is not set', async () => { const result = await settings.getHostLanguage(); expect(result).toBeUndefined(); }); }); describe('setLibretranslateBaseUrl', () => { it('should set the LibreTranslate base URL in the database', async () => { const value = 'https://example.com'; await settings.setLibretranslateBaseUrl(value); const result = await settings.getLibretranslateBaseUrl(); expect(result).toEqual(value); }); }); describe('getLibretranslateBaseUrl', () => { it('should return null if the LibreTranslate base URL is not set', async () => { const result = await settings.getLibretranslateBaseUrl(); expect(result).toBeUndefined(); }); }); describe('setWhisperModel', () => { it('should set the Whisper model in the database', async () => { const value = 'base'; await settings.setWhisperModel(value); const result = await settings.getWhisperModel(); expect(result).toEqual(value); }); }); describe('setWhisperModel', () => { it('should set the Whisper model in the database', async () => { const value = 'base'; await settings.setWhisperModel(value); const result = await settings.getWhisperModel(); expect(result).toEqual(value); }); }); describe('getWhisperModel', () => { it('should return null if the Whisper model is not set', async () => { const result = await settings.getWhisperModel(); expect(result).toBeUndefined(); }); }); });