From 7be149dd846ab2451d77db0a89dcf73ba40905c9 Mon Sep 17 00:00:00 2001 From: przemyslawpluta Date: Thu, 14 Jan 2016 22:12:07 +0000 Subject: [PATCH] update tests --- package.json | 2 +- test/download.js | 19 +++++++++++++------ test/extractors.js | 4 ++++ test/getFormat.js | 4 ++++ test/getInfo.js | 26 +++++++++++++++++--------- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 562da51..e190085 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/download.js b/test/download.js index 26bb7d4..e6d4c47 100644 --- a/test/download.js +++ b/test/download.js @@ -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; @@ -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); @@ -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); @@ -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; @@ -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); @@ -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); @@ -109,6 +114,7 @@ vows.describe('download').addBatch({ }, 'a video with subtitles': { topic: function() { + 'use strict'; try { fs.unlinkSync(path.join(__dirname, subtitleFile)); } catch (err) {} @@ -116,7 +122,8 @@ vows.describe('download').addBatch({ }, '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)); diff --git a/test/extractors.js b/test/extractors.js index d536e9f..50911eb 100644 --- a/test/extractors.js +++ b/test/extractors.js @@ -5,10 +5,12 @@ 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); } @@ -16,10 +18,12 @@ vows.describe('getExtractors').addBatch({ '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); } diff --git a/test/getFormat.js b/test/getFormat.js index fb904ff..ef7a29b 100644 --- a/test/getFormat.js +++ b/test/getFormat.js @@ -10,10 +10,12 @@ 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); } @@ -21,10 +23,12 @@ vows.describe('getFormats').addBatch({ '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); } diff --git a/test/getInfo.js b/test/getInfo.js index 0a8e9ac..daab7d7 100644 --- a/test/getInfo.js +++ b/test/getInfo.js @@ -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'); @@ -24,8 +25,8 @@ 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); @@ -33,11 +34,13 @@ vows.describe('getInfo').addBatch({ }, '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); @@ -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'); @@ -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'); @@ -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); @@ -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); @@ -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);