forked from Zod-/jsVideoUrlParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.test.js
59 lines (56 loc) · 1.86 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
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);
expect(newParser().create({ videoInfo: { provider: 'template' } })).toBe(undefined);
expect(newParser().create({ videoInfo: { provider: 'template', mediaType: 'video' } })).toBe(undefined);
expect(newParser().create({ videoInfo: { provider: 'template', mediaType: 'video' }, format: 'short' })).toBe(undefined);
expect(newParser().create({ videoInfo: { provider: 'template', mediaType: 'playlist' } })).toBe(undefined);
expect(newParser().create({ videoInfo: { provider: 'template', mediaType: 'playlist' }, format: 'short' })).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',
],
});
});