test: add vtt parser tests for invalid timestamps, cue settings and multiline cues

This commit is contained in:
2026-06-24 16:08:03 +02:00
committed by Milas Holsting
parent 2565cdfcc7
commit 76cee8ce21

View File

@@ -28,4 +28,31 @@ World
{ start: 2, end: 3, text: "World" },
]);
});
test("returns zero for invalid timestamps", () => {
assert.equal(parseVttTime(""), 0);
assert.equal(parseVttTime("not a timestamp"), 0);
assert.equal(parseVttTime("00:bad"), 0);
});
test("ignores cue settings and strips html tags", () => {
const cues = parseVtt(`WEBVTT
00:10.000 --> 00:12.000 align:start position:0%
<b>Bold</b> & plain
`);
assert.deepEqual(cues, [{ start: 10, end: 12, text: "Bold & plain" }]);
});
test("joins multiline cue text", () => {
const cues = parseVtt(`WEBVTT
00:00.000 --> 00:03.000
First line
Second line
`);
assert.deepEqual(cues, [{ start: 0, end: 3, text: "First line\nSecond line" }]);
});
});