-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
46 lines (46 loc) · 2.21 KB
/
test.js
File metadata and controls
46 lines (46 loc) · 2.21 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
//TODO: Create async tests.
var assert = require('assert'),
MetaInfo = require('./')();
function detect () {
var errors = [], pass = 0;
try {
assert('error' in MetaInfo.detect('no url'),"\"detect('no url')\" should return an error.");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://www.youtube.com/watch?v=ZRAr354usf8";
assert(MetaInfo.detect(url).api === "youtubecom","\"detect('"+url+"').api\" should return \"youtubecom\".");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://www.imdb.com/title/tt0387808/?ref_=nv_sr_1";
assert(MetaInfo.detect(url).api === "imdbcom","\"detect('"+url+"').api\" should return \"imdbcom\".");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://vimeo.com/61969130";
assert(MetaInfo.detect(url).id === "61969130","\"detect('"+url+"').id\" should return \"61969130\".");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://bambuser.com/v/3453034";
assert(MetaInfo.detect(url).needkey === true,"\"detect('"+url+"').needkey\" should return true.");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://bambuser.com/v/3453034";
assert(MetaInfo.detect(url).needkey === true,"\"detect('"+url+"').needkey\" should return true.");
pass++;
} catch (e) { errors.push(e.message); }
try {
var url = "http://trakt.tv/show/under-the-dome";
assert(MetaInfo.detect(url).id.toString() === "show,under-the-dome","\"detect('"+url+"').id\" should return [\"show\",\"under-the-dome\"].");
pass++;
} catch (e) { errors.push(e.message); }
console.log("[Detect] Number of errors found: "+errors.length+" - Tests passed: "+pass+" ("+((pass/(errors.length+pass)*100))+"%)");
errors.forEach(function(err) { console.log('\033[1;31mERROR:\033[0m '+err); });
return !(errors.length);
};
if ([detect()].indexOf(false) !== -1) {
process.exit(1);
};