🎥 Make videos programmatically with React
Merge remote-tracking branch 'origin/main' into fix/caption-empty-segments
JonnyBurger866c2f6cf6d2
diff --cc packages/captions/src/test/ensure-max-characters.test.tsindex 0d9492a988,0590957595..7da62b4420--- a/packages/captions/src/test/ensure-max-characters.test.ts+++ b/packages/captions/src/test/ensure-max-characters.test.ts@@@ -159,31 -43,27 +43,52 @@@ test('Ensure max characters per line',});});+ test('Preserves spaces between words within a caption', () => {+ const caption: Caption = {+ text: 'Hello world again',+ startMs: 0,+ endMs: 1000,+ timestampMs: 500,+ confidence: 1,+ };+ const {segments} = ensureMaxCharactersPerLine({+ captions: [caption],+ maxCharsPerLine: 100,+ });++ expect(+ segments[0]+ .map((word) => word.text)+ .join('')+ .trim(),+ ).toBe(caption.text);+ });++test('Does not emit empty segments before oversized words', () => {+ const first: Caption = {+ text: ' extraordinary',+ startMs: 0,+ endMs: 1000,+ timestampMs: 500,+ confidence: 1,+ pageBreakAfter: true,+ };+ const second: Caption = {+ text: ' caption',+ startMs: 1000,+ endMs: 2000,+ timestampMs: 1500,+ confidence: 1,+ };++ expect(+ ensureMaxCharactersPerLine({+ captions: [first, second],+ maxCharsPerLine: 4,+ }),+ ).toEqual({segments: [[first], [second]]});+});+test('Does not emit standalone whitespace captions', () => {const captions: Caption[] = [{