From adcc43338123adf4f4f9c6b2163ff86ec807cf40 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Tue, 2 Aug 2011 17:09:26 -0400 Subject: [PATCH] [#674] Implementation tests --- test/popcorn.unit.js | 83 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 7d19d05..e4a4f93 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -500,7 +500,7 @@ test("roundTime", function () { }); - + test("exec", function () { QUnit.reset(); @@ -724,6 +724,81 @@ test("Popcorn.events.hooks: canplayall fires immediately if ready", function() { */ +module("Popcorn Locale"); + +test( "Popcorn.locale object", function() { + + var api = { + get: "function", + set: "function", + broadcast: "function" + }, + locale = navigator.language, + parts = locale.split("-"), + + stub = { + i18n: locale, + language: parts[ 0 ], + region: parts[ 1 ] + }, + $pop = Popcorn("#video"), + expects = 12, + count = 0; + + expect( expects ); + + function plus() { + if ( ++count == expects ) { + start(); + } + } + + stop( 10000 ); + + ok( Popcorn.locale, "Popcorn.locale exists"); + plus(); + + equal( typeof Popcorn.locale, "object", "Popcorn.locale is an object"); + plus(); + + Popcorn.forEach( api, function( type, method ) { + ok( Popcorn.locale[ method ], Popcorn.locale[ method ] + " exists" ); + plus(); + equal( typeof Popcorn.locale[ method ], type, Popcorn.locale[ method ] + " is a " + type ); + plus(); + }); + + deepEqual( Popcorn.locale.get(), stub, "Popcorn.locale.get() === navigator.language (" + JSON.stringify(stub) + ") whenever possible" ); + plus(); + + Popcorn.forEach( Popcorn.locale.get(), function( val, prop ) { + equal( val, stub[ prop ], "locale matches stub" ); + plus(); + }); + + + Popcorn.locale.set("fr-CA"); + + + $pop.listen("locale:changed", function() { + + var locale = "fr-CA", + parts = locale.split("-"), + stub = { + i18n: locale, + language: parts[ 0 ], + region: parts[ 1 ] + }; + + Popcorn.forEach( Popcorn.locale.get(), function( val, prop ) { + equal( val, stub[ prop ], "locale matches updated stub" ); + plus(); + }); + }); + + +}); + module("Popcorn Position"); test("position", function () { @@ -1330,9 +1405,9 @@ test("Start Zero Immediately", function () { end: function() {} }); - $pop.zero({ - start:0, - end: 2 + $pop.zero({ + start:0, + end: 2 }); }); test("Update Timer", function () { -- 2.43.0