aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-01-07 09:12:27 -0500
committerScott González <scott.gonzalez@gmail.com>2012-01-07 09:12:27 -0500
commit31ebe7e7da7d7ce737a1feb3b19dec047e88a3a5 (patch)
tree960d34f7841169d909d72ea77e13b26a521614c2 /tests/unit
parentf63820769d99ccbf6d0178322ffe75b7b321277b (diff)
downloadjquery-ui-31ebe7e7da7d7ce737a1feb3b19dec047e88a3a5.tar.gz
jquery-ui-31ebe7e7da7d7ce737a1feb3b19dec047e88a3a5.zip
Spinner: Allow strings for min, max, and step options, converting immediately to numbers based on numberFormat and culture.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/spinner/spinner_options.js50
1 files changed, 48 insertions, 2 deletions
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js
index 81f434fc6..0be59bd07 100644
--- a/tests/unit/spinner/spinner_options.js
+++ b/tests/unit/spinner/spinner_options.js
@@ -144,24 +144,56 @@ test( "max", function() {
equals( element.val(), 1000, "value not constrained on init" );
element.spinner( "value", 1000 );
- equals( element.val(), 100, "max constrained if value method is greater" );
+ equals( element.val(), 100, "max constrained in value method" );
element.val( 1000 ).blur();
equals( element.val(), 1000, "max not constrained if manual entry" );
});
+test( "max, string", function() {
+ expect( 3 );
+ var element = $( "#spin" )
+ .val( 1000 )
+ .spinner({
+ max: "$100.00",
+ numberFormat: "C",
+ culture: "en"
+ });
+ equals( element.val(), "$1,000.00", "value not constrained on init" );
+ equals( element.spinner( "option", "max" ), 100, "option converted to number" );
+
+ element.spinner( "value", 1000 );
+ equals( element.val(), "$100.00", "max constrained in value method" );
+});
+
test( "min", function() {
expect( 3 );
var element = $( "#spin" ).val( -1000 ).spinner({ min: -100 });
equals( element.val(), -1000, "value not constrained on init" );
element.spinner( "value", -1000 );
- equals( element.val(), -100, "min constrained if value method is greater" );
+ equals( element.val(), -100, "min constrained in value method" );
element.val( -1000 ).blur();
equals( element.val(), -1000, "min not constrained if manual entry" );
});
+test( "min, string", function() {
+ expect( 3 );
+ var element = $( "#spin" )
+ .val( -1000 )
+ .spinner({
+ min: "-$100.00",
+ numberFormat: "C",
+ culture: "en"
+ });
+ equals( element.val(), "($1,000.00)", "value not constrained on init" );
+ equals( element.spinner( "option", "min" ), -100, "option converted to number" );
+
+ element.spinner( "value", -1000 );
+ equals( element.val(), "($100.00)", "min constrained in value method")
+});
+
test( "step, 2", function() {
expect( 3 );
var element = $( "#spin" ).val( 0 ).spinner({ step: 2 });
@@ -187,4 +219,18 @@ test( "step, 0.7", function() {
equals( element.val(), "0.7", "stepUp" );
});
+test( "step, string", function() {
+ expect( 2 );
+ var element = $("#spin").val( 0 ).spinner({
+ step: "$0.70",
+ numberFormat: "C",
+ culture: "en"
+ });
+
+ equals( element.spinner( "option", "step" ), 0.7, "option converted to number" );
+
+ element.spinner( "stepUp" );
+ equals( element.val(), "$0.70", "stepUp" );
+});
+
})( jQuery );