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
fent committed Mar 14, 2014
1 parent 82aeb41 commit c4ab33d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ var video = 'http://www.youtube.com/watch?v=90AiXO1pAiA';
vows.describe('download').addBatch({
'a video': {
'topic': function() {
var dl = ytdl.download(video, __dirname, ['-f', '18']),
var dl = ytdl(video, ['-f', '18']),
cb = this.callback;

dl.on('error', cb);

var progress;
dl.on('progress', function(data) {
progress = data;
});
dl.on('info', function(info) {
var pos = 0;
var progress;

dl.on('data', function(data) {
pos += data.length;
progress = pos / info.size;
});

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

var filepath = path.join(__dirname, info.filename);
dl.pipe(fs.createWriteStream(filepath));
});
},

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

assert.isObject(progress);
assert.isString(progress.percent);
assert.isString(progress.speed);
assert.isString(progress.eta);

assert.equal(progress, 1);
assert.isObject(data);
assert.equal(data.id, '90AiXO1pAiA');
assert.isTrue(/lol-90AiXO1pAiA/.test(data.filename));
assert.equal(data.size, '738.28KiB');
assert.isNumber(data.timeTakenms);
assert.isString(data.timeTaken);
assert.isNumber(data.averageSpeedBytes);
assert.isString(data.averageSpeed);
assert.equal(data.size, 756000);
},

'file was downloaded': function(err, progress, data) {
Expand Down

0 comments on commit c4ab33d

Please sign in to comment.