Browse Source

Add tests for media-frag parsing

tags/v0.1.0
Gerben 5 years ago
parent
commit
a06e1b3566
3 changed files with 3046 additions and 117 deletions
  1. +36
    -0
      app/util/parse-media-fragment-identifier.test.js
  2. +2987
    -116
      package-lock.json
  3. +23
    -1
      package.json

+ 36
- 0
app/util/parse-media-fragment-identifier.test.js View File

@@ -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);
});
}

+ 2987
- 116
package-lock.json
File diff suppressed because it is too large
View File


+ 23
- 1
package.json View File

@@ -9,13 +9,35 @@
],
"scripts": {
"dev": "webextension-toolbox dev",
"build": "webextension-toolbox build"
"build": "webextension-toolbox build",
"test": "ava"
},
"devDependencies": {
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"ava": "^2.4.0",
"webextension-toolbox": "latest"
},
"dependencies": {
"delay": "^4.3.0",
"waveform-playlist": "^3.0.4"
},
"ava": {
"require": [
"@babel/register"
]
},
"babel": {
"retainLines": true,
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
}

Loading…
Cancel
Save