|
|
@@ -1,8 +1,18 @@ |
|
|
|
import test from 'ava'; |
|
|
|
|
|
|
|
import parse from './parse-media-fragment-identifier.js'; |
|
|
|
import { |
|
|
|
createMediaFragmentIdentifier, |
|
|
|
parseMediaFragmentIdentifier, |
|
|
|
} from './media-fragment-identifier.js'; |
|
|
|
|
|
|
|
const inputResultPairs = { |
|
|
|
const creatorResultInputPairs = { |
|
|
|
't=12.345,67.89': { start: 12.345, end: 67.89 }, |
|
|
|
't=,67.89': { end: 67.89 }, |
|
|
|
't=0,67.89': { start: 0, end: 67.89 }, |
|
|
|
't=12.345': { start: 12.345 }, |
|
|
|
}; |
|
|
|
|
|
|
|
const parserInputResultPairs = { |
|
|
|
't=1,2': { start: 1, end: 2 }, |
|
|
|
't=npt:1,2': { start: 1, end: 2 }, |
|
|
|
't=,2': { start: 0, end: 2 }, |
|
|
@@ -27,10 +37,18 @@ const inputResultPairs = { |
|
|
|
't=10%2C20': { start: 10, end: 20 }, |
|
|
|
't=%6ept:10': { start: 10, end: undefined }, |
|
|
|
't=npt%3a10': { start: 10, end: undefined }, |
|
|
|
}; |
|
|
|
|
|
|
|
// Test creating. |
|
|
|
for (const [expectedResult, input] of Object.entries(creatorResultInputPairs)) { |
|
|
|
test(`Correctly create fragment '${expectedResult}'`, t => { |
|
|
|
t.is(createMediaFragmentIdentifier(input), expectedResult); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
for (const [input, expectedResult] of Object.entries(inputResultPairs)) { |
|
|
|
// Test parsing. |
|
|
|
for (const [input, expectedResult] of Object.entries(parserInputResultPairs)) { |
|
|
|
test(`Correctly parse input '${input}'`, t => { |
|
|
|
t.deepEqual(parse(input), expectedResult); |
|
|
|
t.deepEqual(parseMediaFragmentIdentifier(input), expectedResult); |
|
|
|
}); |
|
|
|
} |