From: Christopher De Cairos Date: Tue, 7 Jun 2011 17:29:44 +0000 (-0400) Subject: cleaned up the branch so that the only changes are the tests that I added X-Git-Tag: v0.7^2~49^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=3a7f3d0157adcc3504df85d58f2bff6ce010e133;p=popcorn-js.git cleaned up the branch so that the only changes are the tests that I added --- diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 71d84ce..dffedc3 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -492,6 +492,86 @@ test("exec", function () { }); +test( "Popcorn.extend", function () { + + QUnit.reset(); + + expect( 12 ); + + var dest = {}, + obj1 = { + "key11" : "value", + "key12" : 9001, + "key13" : function() { return true; } + }, + obj2 = { + "key21" : "String", + "key22" : 9002, + "key23" : function() { return false; } + }, + obj3 = Popcorn.extend(dest, obj1); + + for ( prop in obj1 ) { + equal ( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop ); + } + + equal ( typeof dest["key13"], "function","dest[key13] is a function"); + + dest = {}; + + obj3 = Popcorn.extend( dest, obj1, obj2 ); + + for ( var prop in obj1 ) { + equal ( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop + ", when extending 2 objects" ); + } + + for ( var prop in obj2 ) { + equal ( dest.hasOwnProperty( prop ), true, "{dest} has property: " + prop + ", when extending 2 objects" ); + } + + equal ( typeof dest["key13"], "function","dest[key13] is a function"); + + equal ( typeof dest["key23"], "function","dest[key23] is a function"); + +}); + +test( "Popcorn.events", function() { + + QUnit.reset() + expect(43); + + var eventTypes = [ "UIEvents", "MouseEvents", "Events" ], + natives = "", + events, + eventsReturned, + idx = 0, + len, + okay = true; + + eventTypes.forEach (function( e ) { + ok(Popcorn.Events[e], e + " Exists") + }); + + natives = Popcorn.Events[eventTypes[0]] + " " + Popcorn.Events[eventTypes[1]] + " " + Popcorn.Events[eventTypes[2]]; + events = natives.split( /\s+/g ); + eventsReturned = Popcorn.events.all; + len = events.length; + + for ( ; idx++ < len ; ) { + okay = events[idx] === eventsReturned[idx]; + } + + ok( okay, "Native events are correctly being handled"); + + equals( typeof Popcorn.Events.Natives, "string", "Popcorn.Events.Natives is an object" ); + equals( typeof Popcorn.events, "object", "Popcorn.events is an object" ); + + Popcorn.forEach( eventsReturned, function ( e ) { + ok (Popcorn.events.isNative ( e ), e + " is a native event"); + }); + +}); + module("Popcorn Position"); test("position", function () {