From 1f140033b59f335fdda1b6317306acb956251972 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 11 Feb 2011 12:48:21 -0500 Subject: [PATCH] fixed unit test --- test/popcorn.unit.js | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 6b72db7..74da5e5 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -69,26 +69,37 @@ test("Utility", function () { }); test("Instances", function() { - expect(8); - - equals( typeof Popcorn.addInstance, "function" , "Popcorn.addInstance is a provided utility function"); - equals( typeof Popcorn.removeInstance, "function" , "Popcorn.removeInstance is a provided utility function"); - equals( typeof Popcorn.getInstanceById, "function" , "Popcorn.getInstanceById is a provided utility function"); - equals( typeof Popcorn.instanceIds, "object" , "Popcorn.instanceIds is a provided cache object"); - ok( "length" in Popcorn.instances && "join" in Popcorn.instances, "Popcorn.error is a provided cache array"); - - var instance; + var popped = Popcorn("#video"); + var popped2 = Popcorn("#video"); + var popped3 = Popcorn("#video"); + var expects = 9, + count = 0; - for ( var prop in Popcorn.instanceIds ) { - - instance = Popcorn.getInstanceById( prop ); - - ok( instance.video, "Stored instance as a `video` property" ); - ok( instance.data, "Stored instance as a `data` property" ); - ok( instance instanceof Popcorn, "instance instanceof Popcorn" ); + expect(expects); - } + function plus(){ if ( ++count == expects ) start(); } + stop(); + ok( typeof Popcorn.addInstance === "function" , "Popcorn.addInstance is a provided utility function"); + plus(); + ok( typeof Popcorn.removeInstance === "function" , "Popcorn.removeInstance is a provided utility function"); + plus(); + ok( typeof Popcorn.getInstanceById === "function" , "Popcorn.getInstanceById is a provided utility function"); + plus(); + ok( typeof Popcorn.instanceIds === "object" , "Popcorn.instanceIds is a provided cache object"); + plus(); + ok( "length" in Popcorn.instances && "join" in Popcorn.instances, "Popcorn.instances is a provided cache array"); + plus(); + var instance; + instance = Popcorn.getInstanceById("video"); + ok( instance.video, "Stored instance as a `video` property" ); + plus(); + ok( instance.data, "Stored instance as a `data` property" ); + plus(); + ok( instance instanceof Popcorn, "instance instanceof Popcorn" ); + plus(); + ok( 3 === Popcorn.instances.length, "There are 3 instances of Popcorn" ); + plus(); }); test("guid", function () { -- 2.43.0