Files
DeepTutor/web/tests/transcript-search.test.ts
Bingxi Zhao (Frank) 04040a2c06 release: v1.6.5
Ship a content workspace you choose, one exec tool for every language,
Mastery Path modes that gate its tools, and Settings that grades
readiness instead of listing faults.

Release notes: assets/releases/ver1-6-5.md
2026-09-06 13:46:29 +08:00

25 lines
874 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { stepTranscriptMatch, transcriptMatchIndexes } from '../lib/transcript-search'
const cues = [
{ text: 'Fourier transform' },
{ text: 'A geometric interpretation' },
{ text: 'Inverse FOURIER transform' },
]
test('transcript search is trimmed and case-insensitive', () => {
assert.deepEqual(transcriptMatchIndexes(cues, ' fourier '), [0, 2])
assert.deepEqual(transcriptMatchIndexes(cues, 'geometric'), [1])
assert.deepEqual(transcriptMatchIndexes(cues, ''), [])
})
test('transcript match navigation wraps in both directions', () => {
assert.equal(stepTranscriptMatch(-1, 3, 1), 0)
assert.equal(stepTranscriptMatch(-1, 3, -1), 2)
assert.equal(stepTranscriptMatch(2, 3, 1), 0)
assert.equal(stepTranscriptMatch(0, 3, -1), 2)
assert.equal(stepTranscriptMatch(0, 0, 1), -1)
})