feat: publish CodexPi contest snapshot
Some checks are pending
Qualité / tests (push) Waiting to run
Some checks are pending
Qualité / tests (push) Waiting to run
This commit is contained in:
35
frontend/tests/speech.test.ts
Normal file
35
frontend/tests/speech.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { speechTextFromMarkdown, splitSpeechText } from '../src/speech.ts'
|
||||
|
||||
test('markdown is converted to natural speech without fenced code or URLs', () => {
|
||||
const markdown = `# Résultat
|
||||
|
||||
Voici **la réponse** avec [la documentation](https://example.com/docs) et \`npm test\`.
|
||||
|
||||
\`\`\`ts
|
||||
const secret = 'not read aloud'
|
||||
\`\`\`
|
||||
|
||||
- Premier point
|
||||
- Deuxième point`
|
||||
|
||||
const spoken = speechTextFromMarkdown(markdown)
|
||||
|
||||
assert.match(spoken, /Résultat/)
|
||||
assert.match(spoken, /la réponse/)
|
||||
assert.match(spoken, /la documentation/)
|
||||
assert.match(spoken, /npm test/)
|
||||
assert.match(spoken, /Bloc de code omis/)
|
||||
assert.doesNotMatch(spoken, /https|secret|\*\*|```/)
|
||||
})
|
||||
|
||||
test('long speech is split into short non-empty chunks without losing text', () => {
|
||||
const text = `${'Une phrase assez longue. '.repeat(18)}Dernière phrase.`
|
||||
const chunks = splitSpeechText(text, 180)
|
||||
|
||||
assert.ok(chunks.length > 1)
|
||||
assert.ok(chunks.every(chunk => chunk.length > 0 && chunk.length <= 180))
|
||||
assert.equal(chunks.join(' '), text.replace(/\s+/g, ' ').trim())
|
||||
})
|
||||
Reference in New Issue
Block a user