Skip to content

Commit

Permalink
tts test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbonamy committed May 17, 2024
1 parent a421d15 commit 5db7102
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/tts.test.ts
Original file line number Diff line number Diff line change
@@ -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' })
})
4 changes: 4 additions & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*',
]
},
Expand Down

0 comments on commit 5db7102

Please sign in to comment.