mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 23:54:25 +00:00
feat(video): show saved transcripts in the player
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createTranscriptTimeline } from './transcript-timeline'
|
||||
|
||||
describe('createTranscriptTimeline', () => {
|
||||
it('uses inclusive starts and exclusive ends for adjacent segments and gaps', () => {
|
||||
const at = createTranscriptTimeline([
|
||||
{ id: 'later', startMs: 2000, endMs: 2500, text: '' },
|
||||
{ id: 'first', startMs: 300, endMs: 1000, text: '' },
|
||||
{ id: 'second', startMs: 1000, endMs: 1700, text: '' },
|
||||
])
|
||||
|
||||
expect(at(0)).toBeUndefined()
|
||||
expect(at(300)).toBe('first')
|
||||
expect(at(1000)).toBe('second')
|
||||
expect(at(1700)).toBeUndefined()
|
||||
expect(at(2000)).toBe('later')
|
||||
expect(at(2500)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('finds the latest active start when a shorter segment overlaps a longer one', () => {
|
||||
const at = createTranscriptTimeline([
|
||||
{ id: 'long', startMs: 0, endMs: 4000, text: '' },
|
||||
{ id: 'short', startMs: 1050, endMs: 1120, text: '' },
|
||||
])
|
||||
|
||||
expect(at(1049.5)).toBe('long')
|
||||
expect(at(1050)).toBe('short')
|
||||
expect(at(1120)).toBe('long')
|
||||
expect(at(4000)).toBeUndefined()
|
||||
expect(createTranscriptTimeline([])(0)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user