|
|
@@ -0,0 +1,36 @@ |
|
|
|
import test from 'ava'; |
|
|
|
|
|
|
|
import parse from './parse-media-fragment-identifier.js'; |
|
|
|
|
|
|
|
const inputResultPairs = { |
|
|
|
't=1,2': { start: 1, end: 2 }, |
|
|
|
't=npt:1,2': { start: 1, end: 2 }, |
|
|
|
't=,2': { start: 0, end: 2 }, |
|
|
|
't=1': { start: 1, end: undefined }, |
|
|
|
't=1.234': { start: 1.234, end: undefined }, |
|
|
|
't=1.234,5.678': { start: 1.234, end: 5.678 }, |
|
|
|
't=1:2': { start: 62, end: undefined }, |
|
|
|
't=1:2.5': { start: 62.5, end: undefined }, |
|
|
|
't=1:2:3.4': { start: 3723.4, end: undefined }, |
|
|
|
't=20,1:2:3.4': { start: 20, end: 3723.4 }, |
|
|
|
't=20.,1:2.': { start: 20, end: 62 }, |
|
|
|
'track=audio&t=10,20': { start: 10, end: 20 }, |
|
|
|
't=10,20&track=audio': { start: 10, end: 20 }, |
|
|
|
't=1,2&t=3': { start: 3, end: undefined }, |
|
|
|
// Below are examples from the spec. |
|
|
|
't=npt:10,20': { start: 10, end: 20 }, |
|
|
|
't=npt:,121.5': { start: 0, end: 121.5 }, |
|
|
|
't=0:02:00,121.5': { start: 120, end: 121.5 }, |
|
|
|
't=npt:120,0:02:01.5': { start: 120, end: 121.5 }, |
|
|
|
'%74=10,20': { start: 10, end: 20 }, |
|
|
|
't=%31%30': { start: 10, end: undefined }, |
|
|
|
't=10%2C20': { start: 10, end: 20 }, |
|
|
|
't=%6ept:10': { start: 10, end: undefined }, |
|
|
|
't=npt%3a10': { start: 10, end: undefined }, |
|
|
|
} |
|
|
|
|
|
|
|
for (const [input, expectedResult] of Object.entries(inputResultPairs)) { |
|
|
|
test(`Correctly parse input '${input}'`, t => { |
|
|
|
t.deepEqual(parse(input), expectedResult); |
|
|
|
}); |
|
|
|
} |