From: secretrobotron Date: Thu, 17 Mar 2011 20:36:41 +0000 (-0400) Subject: Converted test to use qunit. X-Git-Tag: v0.5~13^2~6^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=cb43e4cb18073c8477a8441c0b42af1963233a5d;p=popcorn-js.git Converted test to use qunit. Fixed a couple of manifest tests. --- diff --git a/test/butter.unit.js b/test/butter.unit.js new file mode 100644 index 0000000..427b816 --- /dev/null +++ b/test/butter.unit.js @@ -0,0 +1,242 @@ +$(document).ready(function(){ +var video = document.getElementById('video'); +var popcorn = new Popcorn('#video'); + +var pluginResults; +var pluginOptions; +var manifest = { + about: {name: 'test', version: '0.1', author: 'Bobby Richter', website: 'http://robothaus.org'}, + options: { + start : {elem:'input', type:'text', label:'In'}, + end : {elem:'input', type:'text', label:'Out'}, + target : 'test-target', + } +}; +var plugin = (Popcorn.plugin('test',{ + manifest: manifest, + _setup:function(options){pluginOptions = options; pluginResults='_setup';}, + start:function(options){pluginResults='start'}, + end:function(options){pluginResults='end'} +})); +var pluginInstance = popcorn['test']({start: 1, end: 2}); + +module("Popcorn"); +var tests = [ + { + title: 'Popcorn.registry', + test: function() { + ok(Popcorn.registry, 'exists'); + } + }, + { + title: 'Popcorn.getTrackEvents', + test: function() { + ok(Popcorn.getTrackEvents, 'exists'); + } + }, + { + title: 'Popcorn.getTrackEvents(popcorn) returns correct results', + test: function() { + expect(2); + var results = Popcorn.getTrackEvents(popcorn); + equals(results[0].start, 1, 'start is 1'); + equals(results[0].end, 2, 'end is 2'); + } + }, + { + title: 'Popcorn.getTrackEvents exists', + test: function() { + ok(Popcorn.getTrackEvents, 'exists'); + } + }, + { + title: 'Valid plugins are addressable as p[pluginName]', + test: function() { + ok(popcorn['test'], 'popcorn[\'test\'] exists'); + } + }, + { + title: 'Invalid plugin names yield undefined using p[invalidName]', + test: function() { + ok(popcorn['notValid'] === undefined, 'is undefined'); + } + }, + { + title: 'p[validPluginName] is expected plugin', + test: function() { + equals(popcorn['test'],plugin['test'], 'popcorn[\'test\'] == plugin[\'test\']'); + } + }, + { + title: 'Popcorn.registry must be a list', + test: function() { + expect(2); + ok(Popcorn.registry, 'registry exists'); + equals(typeof(Popcorn.registry), 'object', 'Popcorn.registry is an object'); + } + }, + { + title: 'Popcorn.registry must contain plugins', + test: function() { + equals(Popcorn.registry[0], plugin, 'Popcorn.registry contains test plugin'); + } + }, + { + title: 'plugin.type must exist', + test: function() { + ok(plugin.type, 'exists'); + } + }, + { + title: 'Plugin instance options._natives must exist', + test: function() { + ok(pluginOptions._natives, 'exists'); + } + }, + { + title: 'Plugin instance options.target should exist', + test: function() { + ok(pluginOptions.target, 'exists'); + } + }, + { + title: 'Popcorn.manifest be a list', + test: function() { + expect(2); + ok(Popcorn.manifest, 'Popcorn.manifest exists'); + equals(typeof(Popcorn.manifest), 'object', 'Popcorn.manifest is an object'); + } + }, + { + title: 'Popcorn.manifest must contain plugin manifests', + test: function() { + equals(Popcorn.manifest['test'], manifest); + } + }, + { + title: 'Plugin manifest must contain options property', + test: function() { + ok(Popcorn.manifest['test'].options, 'exists'); + } + }, + { + title: 'popcorn.video exists', + test: function() { + ok(popcorn.video, 'exists'); + } + }, + { + title: 'popcorn.video.currentTime exists', + test: function() { + ok(popcorn.video.currentTime !== undefined, 'exists'); + } + }, + { + title: 'popcorn.video.play exists', + test: function() { + ok(popcorn.video.play, 'exists'); + } + }, + { + title: 'popcorn.video.pause exists', + test: function() { + ok(popcorn.video.pause, 'exists'); + } + }, + { + title: 'popcorn.video.volume exists', + test: function() { + ok(popcorn.video.volume, 'exists'); + } + }, + { + title: 'popcorn.video.duration exists', + test: function() { + ok(popcorn.video.duration !== undefined, 'exists'); + } + }, + { + title: 'popcorn.video.readyState exists', + test: function() { + ok(popcorn.video.readyState !== undefined, 'exists'); + } + }, + { + title: 'popcorn.data exists', + test: function() { + ok(popcorn.data, 'exists'); + } + }, + { + title: 'popcorn.data.trackEvents exists', + test: function() { + ok(popcorn.data.trackEvents, 'exists'); + } + }, + { + title: 'popcorn.data.trackEvents.byStart exists', + test: function() { + ok(popcorn.data.trackEvents.byStart, 'exists'); + } + }, + { + title: 'popcorn.data.history must be a list', + test: function() { + expect(2); + ok(popcorn.data.history, 'history exists'); + equals(typeof(popcorn.data.history), 'object', 'history in an object'); + } + }, + { + title: 'popcorn.getLastTrackEventId exists and works', + test: function() { + expect(2); + ok(popcorn.getLastTrackEventId, 'exists'); + ok(popcorn.getLastTrackEventId(), 'works'); + } + }, + { + title: 'popcorn.getTrackEvents exists and works', + test: function() { + expect(2); + ok(popcorn.getTrackEvents, 'exists'); + ok(popcorn.getTrackEvents(), 'works'); + } + }, + { + title: 'popcorn.getTrackEvents === Popcorn.getTrackEvents(popcorn)', + test: function() { + expect(2); + var tracks1 = popcorn.getTrackEvents(); + var tracks2 = Popcorn.getTrackEvents(popcorn); + equals(tracks1.length, tracks2.length, 'lengths are equal'); + equals(tracks1[0], tracks2[0], 'objects are equal'); + } + }, + { + title: 'popcorn.listen exists && works', + test: function() { + expect(2); + ok(popcorn.listen, 'exists'); + popcorn.listen('ended', function(){}); + for (var i in popcorn.data.events['ended']) { + ok(popcorn.data.events['ended'][i], 'works'); + break; + } //for + } + }, + { + title: 'popcorn.removeTrackEvent exists and works', + test: function() { + expect(2); + ok(popcorn.removeTrackEvent, 'exists'); + popcorn.removeTrackEvent(popcorn.getLastTrackEventId()); + equals(popcorn.getTrackEvents().length, 0, 'works'); + } + }, +]; + +for (var i=0; i Popcorn Butter Test - - - - + + + + + -
-
- Butter Dependency Test -
-
-
+

Butter Popcorn Dependencies

+

+
+

+
    +