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

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fent committed Sep 16, 2011
1 parent 68199c0 commit 1377915
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.mp4
*.webm
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.mp4
*.webm
45 changes: 45 additions & 0 deletions test/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var vows = require('vows')
ytdl = require('./../lib/youtube-dl'),
fs = require('fs'),
path = require('path'),
assert = require('assert'),
video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';


vows.describe('download').addBatch({
'a video': {
'topic': function() {
var dl = ytdl.download(video, __dirname),
cb = this.callback;

dl.on('error', cb);
dl.on('end', function(data) {
cb(null, data);
});
},

'data returned': function(err, data) {
assert.include(data, 'filename');
assert.isString(data.filename);
assert.include(data, 'size');
assert.isString(data.size);
assert.include(data, 'timeTakenms');
assert.isNumber(data.timeTakenms);
assert.include(data, 'timeTaken');
assert.isString(data.timeTaken);
assert.include(data, 'averageSpeedBytes');
assert.isNumber(data.averageSpeedBytes);
assert.include(data, 'averageSpeed');
assert.isString(data.averageSpeed);
},

'file was downloaded': function(err, data) {
// check existance
var filepath = __dirname + '/' + data.filename;
assert.isTrue(path.existsSync(filepath));

// delete file after each test
fs.unlinkSync(filepath);
}
}
}).export(module);
26 changes: 26 additions & 0 deletions test/info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var vows = require('vows')
ytdl = require('./../lib/youtube-dl'),
assert = require('assert'),
video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';


vows.describe('info').addBatch({
'from a video': {
'topic': function() {
ytdl.info(video, this.callback);
},

'info returned': function(err, info) {
assert.include(info, 'title');
assert.isString(info.title);
assert.include(info, 'url');
assert.isString(info.url);
assert.include(info, 'thumbnail');
assert.isString(info.thumbnail);
assert.include(info, 'description');
assert.isString(info.description);
assert.include(info, 'filename');
assert.isString(info.filename);
}
}
}).export(module);

0 comments on commit 1377915

Please sign in to comment.