forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube.test.js
45 lines (43 loc) · 1.49 KB
/
youtube.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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {handleYoutubeTime} from 'utils/youtube';
describe('Utils.YOUTUBE', () => {
test('should correctly parse youtube start time formats', () => {
for (const {link, time} of [
{
link: 'https://www.youtube.com/watch?time_continue=490&v=xqCoNej8Zxo',
time: '&start=490',
},
{
link: 'https://www.youtube.com/watch?start=490&v=xqCoNej8Zxo',
time: '&start=490',
},
{
link: 'https://www.youtube.com/watch?t=490&v=xqCoNej8Zxo',
time: '&start=490',
},
{
link: 'https://www.youtube.com/watch?time=490&v=xqCoNej8Zxo',
time: '&start=490',
},
{
link: 'https://www.youtube.com/watch?time=8m10s&v=xqCoNej8Zxo',
time: '&start=490',
},
{
link: 'https://www.youtube.com/watch?time=1h8m10s&v=xqCoNej8Zxo',
time: '&start=4090',
},
{
link: 'https://www.youtube.com/watch?v=xqCoNej8Zxo',
time: '',
},
{
link: 'https://www.youtube.com/watch?time=&v=xqCoNej8Zxo',
time: '',
},
]) {
expect(handleYoutubeTime(link)).toEqual(time);
}
});
});