From: secretrobotron Date: Thu, 17 Mar 2011 17:19:38 +0000 (-0400) Subject: Added better tests for functions to check their results as well as their existence. X-Git-Tag: v0.6~2^2~6^2~10 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=be56ac49e0cb81fb603cb59cdd7d46b15d4d34f8;p=popcorn-js.git Added better tests for functions to check their results as well as their existence. --- diff --git a/test/butter_test.html b/test/butter_test.html index 29e73c6..1e4c4dc 100644 --- a/test/butter_test.html +++ b/test/butter_test.html @@ -84,6 +84,18 @@ return Popcorn.getTrackEvents !== undefined; } }, + { + title: 'Popcorn.getTrackEvents(popcorn) returns correct results', + test: function() { + var results = Popcorn.getTrackEvents(popcorn); + for (var i in results) { + if (results[i].start === 1 && results[i].end === 2) { + return true; + } //if + } //for + return false; + } + }, { title: 'Popcorn.getTrackEvents exists', test: function() { @@ -102,6 +114,12 @@ return popcorn['notValid'] === undefined; } }, + { + title: 'p[validPluginName] is expected plugin', + test: function() { + return popcorn['test'] === plugin['test']; + } + }, { title: 'Popcorn.registry must be a list', test: function() { @@ -239,27 +257,51 @@ } }, { - title: 'popcorn.getLastTrackEventId exists', + title: 'popcorn.getLastTrackEventId exists and works', test: function() { - return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object'; + var exists = popcorn.getLastTrackEventId !== undefined; + var works = popcorn.getLastTrackEventId() !== undefined; + return exists && works; } }, { - title: 'popcorn.getTrackEvents exists', + title: 'popcorn.getTrackEvents exists and works', test: function() { - return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object'; + console.log(popcorn.getTrackEvents()); + var exists = popcorn.getTrackEvents !== undefined; + var works = popcorn.getTrackEvents(); + return exists && works; } }, { - title: 'popcorn.removeTrackEvent exists', + title: 'popcorn.getTrackEvents === Popcorn.getTrackEvents(popcorn)', test: function() { - return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object'; + console.log(popcorn.getTrackEvents()); + var exists = popcorn.getTrackEvents !== undefined; + var tracks1 = popcorn.getTrackEvents(); + var tracks2 = Popcorn.getTrackEvents(popcorn); + var works = tracks1.length === tracks2.length && tracks1[0] === tracks2[0]; + return exists && works; } }, { - title: 'popcorn.listen exists', + title: 'popcorn.listen exists && works', test: function() { - return popcorn.data.history !== undefined && typeof(popcorn.data.history) === 'object'; + var exists = popcorn.listen !== undefined; + popcorn.listen('ended', function(){}); + for (var i in popcorn.data.events['ended']) { + return exists && true; + } //for + return false; + } + }, + { + title: 'popcorn.removeTrackEvent exists and works', + test: function() { + var exists = popcorn.removeTrackEvent !== undefined; + popcorn.removeTrackEvent(popcorn.getLastTrackEventId()); + var works = popcorn.getTrackEvents().length === 0; + return exists && works; } }, ];