-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.js
More file actions
129 lines (116 loc) · 4.63 KB
/
tests.js
File metadata and controls
129 lines (116 loc) · 4.63 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/** Author Details
* @name Vasu Jain
* @email vj@brk.im
* @date 04/03/15
* @license Gnu Public License (GPL)
*/
/**
* YouTube Test Cases
*/
QUnit.test("YouTube Test" , function(assert) {
var youTubeArrayTrue = [
"https://www.youtube.com/watch?v=WB370ewOklw",
"https://www.youtube.com/embed/WB370ewOklw?autoplay=1",
"https://www.youtube.com/embed/DGD62Pan_z4",
"https://www.youtube.com/watch?feature=player_embedded&v=22CrPtjODPY&app=desktop",
"https://www.youtube.com/watch?v=-SQ2bvbmAMU&list=PLzufeTFnhupxIlcUF3d5tyRrr0CVpmAVh",
"https://www.youtube.com/watch?v=kwijX850Btk",
"https://www.youtube.com/watch?v=kwijX8501_Btk",
"https://www.youtube.com/watch?v=_kwijX850Btk",
"https://www.youtube.com/watch?v=kw_ijX850Btk",
"https://www.youtube.com/watch?v=-kwi-jX850Btk"
];
var youTubeArrayFalse = [
"https://www.youtube.com/v/WB370ewOklw?autoplay=1",
"http://www.youtube.com/watch_popup?v=WB370ewOklw",
"https://www.youtube.com/watch?v=k#wijX850Btk",
"https://www.yoeutube.com/watch?v=-SQ2bvbmAMU&list=PLzufeTFnhupxIlcUF3d5tyRrr0CVpmAVh"
];
for(var i=0; i<youTubeArrayTrue.length; i++) {
assert.ok(checkCurrentTab(youTubeArrayTrue[i], 11), true, "Test:" + i + " pass");
}
for(var j=0; j<youTubeArrayFalse.length; j++) {
assert.notOk(checkCurrentTab(youTubeArrayFalse[j], 12), false, "Test:" + j + " pass");
}
});
/**
* Vimeo Test Cases
*/
QUnit.test("Vimeo Test" , function(assert) {
var vimeoArrayTrue = [
"https://vimeo.com/35514005",
"https://player.vimeo.com/video/35514005?autoplay=1",
"https://vimeo.com/59286998",
"https://player.vimeo.com/video/59286998?autoplay=1"
];
var vimeoArrayFalse = [
"https://player.vivmeo.com/video/59286998?autoplay=1"
];
for(var i=0; i<vimeoArrayTrue.length; i++) {
assert.ok(checkCurrentTab(vimeoArrayTrue[i], 11), true, "Test:" + i + " pass");
}
for(var j=0; j<vimeoArrayFalse.length; j++) {
assert.notOk(checkCurrentTab(vimeoArrayFalse[j], 11), false, "Test:" + j + " pass");
}
});
/**
* Facebook Test Cases
*/
QUnit.test("Facebook Test" , function(assert) {
var fbArrayTrue = [
"https://www.facebook.com/video.php?v=10152541108348990",
"http://www.facebook.com/video/embed?video_id=10152541108348990",
"https://www.facebook.com/video/embed?video_id=625719987572544",
"https://www.facebook.com/video.php?v=625719987572544"
];
var fbArrayFalse = [
"https://www.ffacebook.com/video.php?v=625719987572544"
];
for(var i=0; i<fbArrayTrue.length; i++) {
assert.ok(checkCurrentTab(fbArrayTrue[i], 11), true, "Test:" + i + " pass");
}
for(var j=0; j<fbArrayFalse.length; j++) {
assert.notOk(checkCurrentTab(fbArrayFalse[j], 11), false, "Test:" + j + " pass");
}
});
/**
* DailyMotion Test Cases
*/
QUnit.test("DailyMotion Test" , function(assert) {
var dmArrayTrue = [
"http://www.dailymotion.com/video/x2kcwa1_major-lazer-dj-snake-lean-on-feat-mo-official-music-video_music",
"http://www.dailymotion.com/embed/video/x2kcwa1?autoStart=1",
"http://www.dailymotion.com/video/x182jt2",
"http://www.dailymotion.com/video/xsbrgx_hawaii-s-clouds-an-hdr-timelapse_travel"
];
var dmArrayFalse = [
"http://www.ddailymotion.com/video/xsbrgx_hawaii-s-clouds-an-hdr-timelapse_travel"
];
for(var i=0; i<dmArrayTrue.length; i++) {
assert.ok(checkCurrentTab(dmArrayTrue[i], 11), true, "Test:" + i + " pass");
}
for(var j=0; j<dmArrayFalse.length; j++) {
assert.notOk(checkCurrentTab(dmArrayFalse[j], 11), false, "Test:" + j + " pass");
}
});
/**
* Testing URL trim function
*/
QUnit.test("TrimLongUrl", function(assert) {
var longUrlArray = [
"http://www.dailymotion.com/video/x2kcwa1_major-lazer-dj-snake-lean-on-feat-mo-official-music-video_music",
"http://www.dailymotion.com/embed/video/x2kcwa1?autoStart=1",
"http://www.dailymotion.com/video/xsbrgx_hawaii-s-clouds-an-hdr-timelapse_travel",
"https://www.youtube.com/watch?feature=player_embedded&v=22CrPtjODPY&app=desktop"
];
var shortUrlArray = [
"http://www.dailymotion.com/video/x182jt2",
"https://www.youtube.com/embed/DGD62Pan_z4"
];
for(var i=0; i<longUrlArray.length; i++) {
assert.equal(trimLongUrl(longUrlArray[i], 42).length, 45, "Test:" + i + " pass");
}
for(var j=0; i<shortUrlArray.length; j++) {
assert.equal(trimLongUrl(shortUrlArray[j], 42).length, shortUrlArray[j].length, "Test:" + j + " pass");
}
});