Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslawpluta committed Jan 14, 2016
1 parent 1aa9076 commit 7be149d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"video",
"download"
],
"version": "1.10.5",
"version": "1.10.6",
"repository": {
"type": "git",
"url": "git://github.com/fent/node-youtube-dl.git"
Expand Down
19 changes: 13 additions & 6 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ var video2 = 'https://www.youtube.com/watch?v=179MiZSibco';
var video3 = 'https://www.youtube.com/watch?v=AW8OOp2undg';
var subtitleFile = '1 1 1-179MiZSibco.en.srt';


vows.describe('download').addBatch({
'a video with format specified': {
'topic': function() {
'use strict';
var dl = ytdl(video1, ['-f', '18']);
var cb = this.callback;

Expand All @@ -36,7 +36,8 @@ vows.describe('download').addBatch({
},

'data returned': function(err, progress, data) {
if (err) throw err;
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
Expand All @@ -46,7 +47,8 @@ vows.describe('download').addBatch({
},

'file was downloaded': function(err, progress, data) {
if (err) throw err;
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
Expand All @@ -61,6 +63,7 @@ vows.describe('download').addBatch({
},
'a video with no format specified': {
'topic': function() {
'use strict';
var dl = ytdl(video3);
var cb = this.callback;

Expand All @@ -85,7 +88,8 @@ vows.describe('download').addBatch({
},

'data returned': function(err, progress, data) {
if (err) throw err;
'use strict';
if (err) { throw err; }

assert.equal(progress, 1);
assert.isObject(data);
Expand All @@ -94,7 +98,8 @@ vows.describe('download').addBatch({
},

'file was downloaded': function(err, progress, data) {
if (err) throw err;
'use strict';
if (err) { throw err; }

// Check existance.
var filepath = path.join(__dirname, data._filename);
Expand All @@ -109,14 +114,16 @@ vows.describe('download').addBatch({
},
'a video with subtitles': {
topic: function() {
'use strict';
try {
fs.unlinkSync(path.join(__dirname, subtitleFile));
} catch (err) {}
ytdl.getSubs(video2, { lang: 'en', cwd: __dirname }, this.callback);
},

'subtitles were downloaded': function(err, files) {
if (err) throw err;
'use strict';
if (err) { throw err; }
assert.equal(files[0], subtitleFile);
assert.isTrue(fs.existsSync(path.join(__dirname, subtitleFile)));
fs.unlinkSync(path.join(__dirname, subtitleFile));
Expand Down
4 changes: 4 additions & 0 deletions test/extractors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ var assert = require('assert');
vows.describe('getExtractors').addBatch({
'plain extractors': {
'topic': function() {
'use strict';
ytdl.getExtractors(false, this.callback);
},

'extractors returned': function(err, extractors) {
'use strict';
assert.isNull(err);
assert.isArray(extractors);
}
},

'extractors with description': {
'topic': function() {
'use strict';
ytdl.getExtractors(true, this.callback);
},

'extractors returned': function(err, formats) {
'use strict';
assert.isNull(err);
assert.isArray(formats);
}
Expand Down
4 changes: 4 additions & 0 deletions test/getFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@ var mixcloudvideo =
vows.describe('getFormats').addBatch({
'from a video': {
'topic': function() {
'use strict';
ytdl.getFormats(youtubevideo, this.callback);
},

'formats returned': function(err, formats) {
'use strict';
assert.isNull(err);
assert.isArray(formats);
}
},

'from a mixcloud mix': {
'topic': function() {
'use strict';
ytdl.getFormats(mixcloudvideo, this.callback);
},

'formats returned': function(err, formats) {
'use strict';
assert.isNull(err);
assert.isArray(formats);
}
Expand Down
26 changes: 17 additions & 9 deletions test/getInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ var vows = require('vows');
var ytdl = require('..');
var assert = require('assert');


vows.describe('getInfo').addBatch({
'from a youtube video': {
'topic': function() {
'use strict';
var video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
ytdl.getInfo(video, ['-f', '18/22/37/38'], this.callback);
},

'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isObject(info);
assert.equal(info.id, '90AiXO1pAiA');
Expand All @@ -24,20 +25,22 @@ vows.describe('getInfo').addBatch({
'This is also the original I find it hilarious that there ' +
'are copycat videos!');
assert.equal(info._filename, 'lol-90AiXO1pAiA.mp4');
assert.equal(info.format, '18 - 640x360');
assert.equal(info.duration, '12');
assert.equal(info.format, '18 - 640x360 (medium)');
assert.equal(info.duration, '11');
assert.equal(info.width, 640);
assert.equal(info.height, 360);
assert.isArray(info.formats);
}
},
'from a youtube playlist': {
'topic': function() {
'use strict';
var pl = 'https://www.youtube.com/playlist?list=PLEFA9E9D96CB7F807';
ytdl.getInfo(pl, this.callback);
},

'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isArray(info);
assert.ok(info.length);
Expand All @@ -48,10 +51,12 @@ vows.describe('getInfo').addBatch({
},
'from a soundcloud track': {
'topic': function() {
'use strict';
var video = 'https://soundcloud.com/erasedtapes/kiasmos-bent';
ytdl.getInfo(video, this.callback);
},
'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isObject(info);
assert.equal(info.id, '147055755');
Expand All @@ -66,11 +71,13 @@ vows.describe('getInfo').addBatch({
},
'from a vimeo video': {
'topic': function() {
'use strict';
var video = 'https://vimeo.com/6586873';
ytdl.getInfo(video, this.callback);
},

'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isObject(info);
assert.equal(info.id, '6586873');
Expand All @@ -83,19 +90,21 @@ vows.describe('getInfo').addBatch({
'hobbledehoyrecords.com/store');
assert.equal(info._filename,
'OWEN - good friends, bad habits-6586873.mp4');
assert.equal(info.format, 'h264-sd - 480x272');
assert.equal(info.format, 'http-360p - 480x272');
assert.equal(info.duration, '3:55');
}
},

'from multiple videos': {
'topic': function() {
'use strict';
var vimeo = 'https://vimeo.com/6586873';
var youtube = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
ytdl.getInfo([vimeo, youtube], this.callback);
},

'info returned': function(err, info) {
'use strict';
assert.isNull(err);
assert.isArray(info);
assert.equal(info.length, 2);
Expand All @@ -109,10 +118,9 @@ vows.describe('getInfo').addBatch({
'hobbledehoyrecords.com/store');
assert.equal(info[0]._filename,
'OWEN - good friends, bad habits-6586873.mp4');
assert.equal(info[0].format, 'h264-sd - 480x272');
assert.equal(info[0].format, 'http-360p - 480x272');
assert.equal(info[0].duration, '3:55');

assert.equal(info[1].id, '90AiXO1pAiA');
assert.equal(info[1].id, '90AiXO1pAiA');
assert.equal(info[1].format_id, '18');
assert.equal(info[1].title, 'lol');
assert.isString(info[1].url);
Expand All @@ -123,8 +131,8 @@ vows.describe('getInfo').addBatch({
'This is also the original I find it hilarious that there ' +
'are copycat videos!');
assert.equal(info[1]._filename, 'lol-90AiXO1pAiA.mp4');
assert.equal(info[1].format, '18 - 640x360');
assert.equal(info[1].duration, '12');
assert.equal(info[1].format, '18 - 640x360 (medium)');
assert.equal(info[1].duration, '11');
assert.equal(info[1].width, 640);
assert.equal(info[1].height, 360);
assert.isArray(info[1].formats);
Expand Down

0 comments on commit 7be149d

Please sign in to comment.