forked from Zod-/jsVideoUrlParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.test.js
72 lines (68 loc) · 1.69 KB
/
template.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const Template = require('./template');
const UrlParser = require('../urlParser');
const {
testUrls,
} = require('../testUrls');
function newParser() {
const parser = new UrlParser();
parser.bind(new Template());
return parser;
}
test('Template: undefined', () => {
expect(newParser().parse('https://template.com')).toBe(undefined);
expect(newParser().parse('https://temp.com')).toBe(undefined);
});
test('Template: video urls', () => {
// Parse urls to test against the videoInfo object
// Create urls with the videoInfo objects to test against the format urls
testUrls(newParser(), {
videoInfo: {
provider: 'template',
id: 'abcde',
mediaType: 'video',
},
formats: {
long: 'https://template.com/example/id/abcde',
short: 'https://temp.com/abcde',
},
urls: [
'https://template.com/example/id/abcde',
'https://temp.com/abcde',
],
});
testUrls(newParser(), {
videoInfo: {
provider: 'template',
id: 'abcde',
mediaType: 'video',
params: {
start: 30,
},
},
formats: {
long: 'https://template.com/example/id/abcde?start=30',
short: 'https://temp.com/abcde?start=30',
},
urls: [
'https://template.com/example/id/abcde?start=30',
'https://temp.com/abcde?start=30',
],
});
});
test('Template: empty urls', () => {
var parser = newParser();
var videoInfo = {
provider: 'template',
id: 'abcde',
mediaType: 'playlist',
};
var resultLong = parser.create({
videoInfo: videoInfo,
});
var resultShort = parser.create({
videoInfo: videoInfo,
format: 'short',
});
expect(resultLong).toBe('');
expect(resultShort).toBe('');
});