diff --git a/tests/unit/tts.test.ts b/tests/unit/tts.test.ts new file mode 100644 index 0000000..b0d6613 --- /dev/null +++ b/tests/unit/tts.test.ts @@ -0,0 +1,27 @@ + +import { vi, beforeEach, expect, test } from 'vitest' +import { store } from '../../src/services/store' +import defaults from '../../defaults/settings.json' +import Tts from '../../src/services/tts' + +vi.mock('openai', async () => { + const OpenAI = vi.fn() + OpenAI.prototype.apiKey = '123' + OpenAI.prototype.audio = { + speech: { + create: vi.fn((opts) => opts.input) + } + } + return { default : OpenAI } +}) + +beforeEach(() => { + store.config = defaults + store.config.engines.openai.apiKey = '123' +}) + +test('Synthetizes text', async () => { + const tts = new Tts(store.config) + const response = await tts.synthetize('hello') + expect(response).toStrictEqual({ type: 'audio', content: 'hello' }) +}) diff --git a/vitest.config.mjs b/vitest.config.mjs index 5c1cc8e..55a842a 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -24,6 +24,10 @@ export default defineConfig({ coverage: { exclude: [ ...coverageConfigDefaults.exclude, + 'src/*.ts', + 'src/automations/macos*.ts', + 'src/automations/robot.ts', + 'src/automations/windows.ts', 'src/vendor/**/*', ] },