aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/spinner/spinner_options.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/spinner/spinner_options.js')
-rw-r--r--tests/unit/spinner/spinner_options.js57
1 files changed, 25 insertions, 32 deletions
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js
index 30155e755..647455fe5 100644
--- a/tests/unit/spinner/spinner_options.js
+++ b/tests/unit/spinner/spinner_options.js
@@ -3,30 +3,27 @@
module( "spinner: options" );
test( "numberFormat, number", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "n"
- });
- equal( element.val(), "1.00", "n" );
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" });
+ equal( element.val(), "0.00", "formatted on init" );
+ element.spinner( "stepUp" );
+ equal( element.val(), "1.00", "formatted after step" );
});
test( "numberFormat, number, simple", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "n0"
- });
- equal( element.val(), "1", "n0" );
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n0" });
+ equal( element.val(), "0", "formatted on init" );
+ element.spinner( "stepUp" );
+ equal( element.val(), "1", "formatted after step" );
});
test( "numberFormat, currency", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "C"
- });
- equal( element.val(), "$1.00", "C" );
+ expect( 2 );
+ var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" });
+ equal( element.val(), "$0.00", "formatted on init" );
+ element.spinner( "stepUp" );
+ equal( element.val(), "$1.00", "formatted after step" );
});
/* TODO figure out how to test this properly
@@ -69,32 +66,31 @@ test("incremental - true (default)", function() {
test( "max", function() {
expect( 3 );
- var element = $( "#spin" ).spinner({ max: 100, value: 1000 });
- equals( element.val(), 100, "max constrained if value option is greater" );
+ var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
+ equals( element.val(), 1000, "value not constrained on init" );
element.spinner( "value", 1000 );
equals( element.val(), 100, "max constrained if value method is greater" );
element.val( 1000 ).blur();
- equals( element.val(), 100, "max constrained if manual entry" );
+ equals( element.val(), 1000, "max not constrained if manual entry" );
});
test( "min", function() {
expect( 3 );
- var element = $( "#spin" ).spinner({ min: -100, value: -1000 });
- equals( element.val(), -100, "min constrained if value option is greater" );
+ 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" );
element.val( -1000 ).blur();
- equals( element.val(), -100, "min constrained if manual entry" );
+ equals( element.val(), -1000, "min not constrained if manual entry" );
});
test( "step, 2", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({ step: 2 });
- equals( element.val(), "0", "value initialized to 0" );
+ expect( 3 );
+ var element = $( "#spin" ).val( 0 ).spinner({ step: 2 });
element.spinner( "stepUp" );
equals( element.val(), "2", "stepUp" );
@@ -107,16 +103,13 @@ test( "step, 2", function() {
});
test( "step, 0.7", function() {
- expect( 2 );
- var element = $("#spin").spinner({
+ expect( 1 );
+ var element = $("#spin").val( 0 ).spinner({
step: 0.7
});
- equals( element.val(), "0", "value initialized to 0" );
element.spinner( "stepUp" );
equals( element.val(), "0.7", "stepUp" );
});
-// TODO: test value
-
})( jQuery );