From 7a7ff193ccb3535f64d69468416468f5b698289b Mon Sep 17 00:00:00 2001 From: rwldrn Date: Sun, 5 Dec 2010 12:52:04 -0500 Subject: [PATCH] Unit test cleanup --- popcorn.js | 22 ++++++++++++---------- test/popcorn.unit.js | 44 ++++++++++++++++++++------------------------ 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/popcorn.js b/popcorn.js index 13d697a..bf658b1 100644 --- a/popcorn.js +++ b/popcorn.js @@ -1,9 +1,3 @@ -// Immediately invoked function expression is used to -// create a pseudo-private scope for our api definition -// a reference to the `window` object is passed into the -// closure and referenced as `global`. This is both -// beneficial for compressors and provides a fast -// reference to the window context (function(global) { // Cache refs to speed up calls to native utils @@ -267,7 +261,11 @@ definition = function ( options ) { - var self = this; + var self = this, + fired = { + start: 0, + end: 0 + }; if ( !options ) { return this; @@ -295,8 +293,10 @@ if ( ~~self.currentTime() === options.start || self.currentTime() === options.start ) { - - setup.start.call(self, event, options); + + !fired.start && setup.start.call(self, event, options); + + fired.start++; } if ( self.currentTime() > options.start && @@ -309,7 +309,9 @@ if ( ~~self.currentTime() === options.end || self.currentTime() === options.end ) { - setup.end.call(self, event, options); + !fired.end && setup.end.call(self, event, options); + + fired.end++; } }); diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 9162feb..6da4877 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -1,4 +1,6 @@ -test("Popcorn API", function () { + +module("Popcorn"); +test("API", function () { var expects = 3, count = 0; @@ -35,21 +37,28 @@ test("Popcorn API", function () { }); -test("Popcorn Utility", function () { +test("Utility", function () { + + // TODO: comprehensive tests for these utilities equals( typeof Popcorn.forEach, "function" , "Popcorn.forEach is a provided utility function"); equals( typeof Popcorn.extend, "function" , "Popcorn.extend is a provided utility function"); + equals( typeof Popcorn.guid, "function" , "Popcorn.guid is a provided utility function"); + equals( typeof Popcorn.sizeOf, "function" , "Popcorn.sizeOf is a provided utility function"); + equals( typeof Popcorn.nop, "function" , "Popcorn.nop is a provided utility function"); }); -test("Popcorn Object", function () { +test("Object", function () { var popped = Popcorn("#video"), methods = "load play pause currentTime mute volume"; - //console.log(popped); + + + console.log(popped); popped.play(); @@ -70,8 +79,9 @@ test("Popcorn Object", function () { }); +module("Popcorn Events"); -test("Popcorn Events Stored By Type", function () { +test("Stored By Type", function () { QUnit.reset(); @@ -135,7 +145,7 @@ test("Popcorn Events Stored By Type", function () { }); -test("Popcorn Events Simulated", function () { +test("Simulated", function () { QUnit.reset(); @@ -177,7 +187,7 @@ test("Popcorn Events Simulated", function () { }); -test("Popcorn Events Real", function () { +test("Real", function () { QUnit.reset(); @@ -227,7 +237,8 @@ test("Popcorn Events Real", function () { }); -test("Popcorn Plugin", function () { +module("Popcorn Plugin") +test("Plugin API", function () { QUnit.reset(); @@ -347,22 +358,7 @@ test("Popcorn Plugin", function () { - - - - - - - - - - - - - - - -test("Popcorn Plugin Extended Events", function () { +test("Events Extended", function () { //QUnit.reset(); -- 2.43.0