Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

elevenlabs-pricing.test.ts

46 lines1.7 KB

1import { describe, expect, it } from 'vitest'
2​
3import {
4 compileElevenLabsSpeechCards,
5 elevenLabsSpeechProduct,
6 parseElevenLabsSpeechPrices,
7} from './elevenlabs-pricing.ts'
8​
9const PAGE = `
10<p>usage is billed in US dollars, not credits. Text to Speech $0.08 per 1,000 characters (multilingual models) or $0.04 (Flash/Turbo). Speech to Text $0.22 per hour.</p>
11<p>Text to Speech $0.08 per 1,000 characters (multilingual models) or $0.04 (Flash/Turbo).</p>
13​
14const SOURCE = {
15 url: 'https://elevenlabs.io/pricing/api',
16 hash: 'abc',
17 extractedAt: '2026-10-03T00:00:00.000Z',
19​
20describe('elevenlabs speech prices', () => {
21 it('does not copy the FAQ summary onto speech products', () => {
22 expect(parseElevenLabsSpeechPrices(PAGE)).toBeNull()
23 expect(compileElevenLabsSpeechCards(PAGE, SOURCE)).toBeNull()
24 })
25​
26 it('refuses a page that does not state the speech product price', () => {
27 expect(parseElevenLabsSpeechPrices('<p>Contact sales</p>')).toBeNull()
28 expect(
29 compileElevenLabsSpeechCards('<p>Contact sales</p>', SOURCE),
30 ).toBeNull()
31 })
32​
33 it('refuses conflicting repeats of the speech price', () => {
34 const conflict = `${PAGE} Text to Speech $0.10 per 1,000 characters (multilingual models) or $0.04 (Flash/Turbo).`
35 expect(parseElevenLabsSpeechPrices(conflict)).toBeNull()
36 })
37​
38 it('assigns Flash and Turbo ids to the half-price product', () => {
39 expect(elevenLabsSpeechProduct('eleven_flash_v2_5')).toBe('flash')
40 expect(elevenLabsSpeechProduct('eleven_turbo_v2_5')).toBe('flash')
41 expect(elevenLabsSpeechProduct('eleven_multilingual_v2')).toBe(
42 'multilingual',
43 )
44 expect(elevenLabsSpeechProduct('eleven_v3')).toBe('multilingual')
45 })
46})