sttMock.test.ts
727 bytes
| 1 | import { describe, expect, it } from 'vitest' |
|---|---|
| 2 | import { createSttMock } from './sttMock' |
| 3 | |
| 4 | describe('sttMock', () => { |
| 5 | it('echoes valid UTF-8 text buffers back as the transcript', async () => { |
| 6 | const stt = createSttMock() |
| 7 | const result = await stt.transcribe(Buffer.from('hello from a test', 'utf8'), 'text/plain') |
| 8 | expect(result).toBe('hello from a test') |
| 9 | }) |
| 10 | |
| 11 | it('returns an incrementing mock transcript for non-text buffers', async () => { |
| 12 | const stt = createSttMock() |
| 13 | const binary = Buffer.from([0xff, 0xfe, 0x00, 0x01, 0x80, 0x80]) |
| 14 | expect(await stt.transcribe(binary, 'audio/webm')).toBe('mock transcript 1') |
| 15 | expect(await stt.transcribe(binary, 'audio/webm')).toBe('mock transcript 2') |
| 16 | }) |
| 17 | }) |
| 18 | |