Permalink
Browse files

Unit test cleanup

  • Loading branch information...
1 parent 9768f67 commit 7a7ff193ccb3535f64d69468416468f5b698289b @rwaldron rwaldron committed Dec 5, 2010
Showing with 32 additions and 34 deletions.
  1. +12 −10 popcorn.js
  2. +20 −24 test/popcorn.unit.js
View
@@ -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++;
}
});
View
@@ -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();

0 comments on commit 7a7ff19

Please sign in to comment.