From 4e2c8ef2a3615d1178b1986a5df6ef10e2fcadfa Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 19 Jan 2012 20:39:19 +0700 Subject: [PATCH] added unit tests for prevent focus zoom option --- tests/unit/select/select_native.js | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/unit/select/select_native.js b/tests/unit/select/select_native.js index 271dbf91..2fff2f9f 100644 --- a/tests/unit/select/select_native.js +++ b/tests/unit/select/select_native.js @@ -65,4 +65,64 @@ $( "#native-refresh" ).selectmenu( 'close' ); ok( true ); }); + + + asyncTest( "The preventFocusZoom option is working as expected", function() { + + var zoomoptiondefault = $.mobile.selectmenu.prototype.options.preventFocusZoom; + $.mobile.selectmenu.prototype.options.preventFocusZoom = true; + + $(document) + .one("vmousedown.test", function(){ + ok( $.mobile.zoom.enabled === false, "zoom is disabled on vmousedown" ); + }) + .one("mouseup.test", function(){ + ok( $.mobile.zoom.enabled === true, "zoom is enabled on mouseup" ); + $.mobile.selectmenu.prototype.options.preventFocusZoom = zoomoptiondefault; + $(document).unbind(".test"); + $( "#select-choice-native" ).selectmenu( "option", "preventFocusZoom", zoomoptiondefault ) + start(); + }); + + $( "#select-choice-native" ) + .selectmenu( "option", "preventFocusZoom", true ) + .parent() + .trigger( "vmousedown" ) + .trigger( "mouseup" ); + + + + + }); + + asyncTest( "The preventFocusZoom option does not manipulate zoom when it is false", function() { + + var zoomstate = $.mobile.zoom.enabled, + zoomoptiondefault = $.mobile.selectmenu.prototype.options.preventFocusZoom; + + + $(document) + .one("vmousedown.test", function(){ + ok( $.mobile.zoom.enabled === zoomstate, "zoom is unaffected on vmousedown" ); + }) + .one("mouseup.test", function(){ + ok( $.mobile.zoom.enabled === zoomstate, "zoom is unaffected on mouseup" ); + $(document).unbind(".test"); + $( "#select-choice-native" ).selectmenu( "option", "preventFocusZoom", zoomoptiondefault ) + start(); + + }); + + $( "#select-choice-native" ) + .selectmenu( "option", "preventFocusZoom", false ) + .parent() + .trigger( "vmousedown" ) + .trigger( "mouseup" ); + + }); + + + + + })(jQuery); \ No newline at end of file