diff --git a/src/__tests__/subtitles/subtitles.test.ts b/src/__tests__/subtitles/subtitles.test.ts index 90d659dd..1962a65f 100644 --- a/src/__tests__/subtitles/subtitles.test.ts +++ b/src/__tests__/subtitles/subtitles.test.ts @@ -5,7 +5,13 @@ import { parseSubtitles, } from "@/backend/helpers/captions"; import { MWCaptionType } from "@/backend/helpers/streams"; -import { ass, srt, visibleSubtitlesTestVtt, vtt } from "./testdata"; +import { + ass, + multilineSubtitlesTestVtt, + srt, + visibleSubtitlesTestVtt, + vtt, +} from "./testdata"; describe("subtitles", () => { it("should return true if given url ends with a known subtitle type", ({ @@ -133,4 +139,13 @@ describe("subtitles", () => { ); expect(delayedVisibleSubtitles3).toHaveLength(1); }); + + it("should parse multiline captions", ({ expect }) => { + const parsed = parseSubtitles(multilineSubtitlesTestVtt); + console.log(parsed[0].content, parsed[0].text); + + expect(parsed[0].text).toBe(`- Test 1\n- Test 2\n- Test 3`); + expect(parsed[1].text).toBe(`- Test 4`); + expect(parsed[2].text).toBe(`- Test 6`); + }); }); diff --git a/src/__tests__/subtitles/testdata.ts b/src/__tests__/subtitles/testdata.ts index a121e705..2cf71004 100644 --- a/src/__tests__/subtitles/testdata.ts +++ b/src/__tests__/subtitles/testdata.ts @@ -53,4 +53,16 @@ Test 2 Test 3 `; -export { vtt, srt, ass, visibleSubtitlesTestVtt }; +const multilineSubtitlesTestVtt = `WEBVTT + +00:00:00.000 --> 00:00:10.000 +- Test 1\n- Test 2\n- Test 3 + +00:00:10.000 --> 00:00:20.000 +- Test 4 + +00:00:20.000 --> 00:00:31.000 +- Test 6 +`; + +export { vtt, srt, ass, visibleSubtitlesTestVtt, multilineSubtitlesTestVtt };