-/*\r
- * spinner_methods.js\r
- */\r
-(function($) {\r
-\r
-module("spinner: methods");\r
-\r
-test("disable", function() {\r
- var el = $("#spin").spinner({ disabled: false }),\r
- val = el.val(),\r
- wrapper = $("#spin").spinner("widget");\r
- \r
- ok(!wrapper.hasClass("ui-spinner-disabled"), "before: wrapper does not have ui-spinner-disabled class");\r
- ok(!el.is(':disabled'), "before: input does not have disabled attribute");\r
-\r
- el.spinner("disable");\r
- ok(wrapper.hasClass("ui-spinner-disabled"), "after: wrapper has ui-spinner-disabled class");\r
- ok(el.is(':disabled'), "after: input has disabled attribute");\r
- \r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP); \r
- equals(val, el.val(), "keyboard - value does not change on key UP");\r
-\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.DOWN);\r
- equals(val, el.val(), "keyboard - value does not change on key DOWN");\r
-\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.PAGE_UP);\r
- equals(val, el.val(), "keyboard - value does not change on key PGUP");\r
-\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.PAGE_DOWN);\r
- equals(val, el.val(), "keyboard - value does not change on key PGDN");\r
- \r
- wrapper.find(":ui-button").first().trigger('mousedown').trigger('mouseup');\r
- equals(val, el.val(), "mouse - value does not change on clicking up button");\r
-\r
- wrapper.find(":ui-button").last().trigger('mousedown').trigger('mouseup');\r
- equals(val, el.val(), "mouse - value does not change on clicking down button");\r
- \r
- el.spinner('stepUp', 6);\r
- equals(6, el.val(), "script - stepUp 6 steps changes value");\r
-\r
- el.spinner('stepDown');\r
- equals(5, el.val(), "script - stepDown 1 step changes value");\r
-\r
- el.spinner('pageUp');\r
- equals(15, el.val(), "script - pageUp 1 page changes value");\r
-\r
- el.spinner('pageDown');\r
- equals(5, el.val(), "script - pageDown 1 page changes value");\r
+(function( $ ) {\r
\r
+module( "spinner: methods" );\r
+\r
+test( "disable", function() {\r
+ expect( 14 );\r
+ var element = $( "#spin" ).spinner({ value: 2 }),\r
+ wrapper = $( "#spin" ).spinner( "widget" );\r
+\r
+ ok( !wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper does not have ui-spinner-disabled class" );\r
+ ok( !element.is( ":disabled" ), "before: input does not have disabled attribute" );\r
+\r
+ element.spinner( "disable" );\r
+ ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" );\r
+ ok( element.is( ":disabled"), "after: input has disabled attribute" );\r
+\r
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );\r
+ equals( 2, element.val(), "keyboard - value does not change on key UP" );\r
+\r
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );\r
+ equals( 2, element.val(), "keyboard - value does not change on key DOWN" );\r
+\r
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );\r
+ equals( 2, element.val(), "keyboard - value does not change on key PGUP" );\r
+\r
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );\r
+ equals( 2, element.val(), "keyboard - value does not change on key PGDN" );\r
+\r
+ wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );\r
+ equals( 2, element.val(), "mouse - value does not change on clicking up button" );\r
+\r
+ wrapper.find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );\r
+ equals( 2, element.val(), "mouse - value does not change on clicking down button" );\r
+\r
+ element.spinner( "stepUp", 6 );\r
+ equals( 8, element.val(), "script - stepUp 6 steps changes value");\r
+\r
+ element.spinner( "stepDown" );\r
+ equals( 7, element.val(), "script - stepDown 1 step changes value" );\r
+\r
+ element.spinner( "pageUp" );\r
+ equals( 17, element.val(), "script - pageUp 1 page changes value" );\r
+\r
+ element.spinner( "pageDown" );\r
+ equals( 7, element.val(), "script - pageDown 1 page changes value" );\r
});\r
\r
-test("enable", function() {\r
- var el = $("#spin").spinner({ disabled: true })\r
- val = el.val(),\r
- wrapper = el.spinner("widget");\r
-\r
- ok(wrapper.hasClass("ui-spinner-disabled"), "before: wrapper has ui-spinner-disabled class");\r
- ok(el.is(':disabled'), "before: input has disabled attribute");\r
- \r
- el.spinner("enable");\r
- \r
- ok(!wrapper.hasClass(".ui-spinner-disabled"), "after: wrapper does not have ui-spinner-disabled class");\r
- ok(!el.is(':disabled'), "after: input does not have disabled attribute");\r
+test( "enable", function() {\r
+ expect( 5 );\r
+ var element = $( "#spin" ).spinner({ disabled: true })\r
+ wrapper = element.spinner( "widget" );\r
+\r
+ ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );\r
+ ok( element.is( ":disabled" ), "before: input has disabled attribute" );\r
+\r
+ element.spinner( "enable" );\r
+\r
+ ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" );\r
+ ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );\r
+\r
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );\r
+ equals( 1, element.val(), "keyboard - value does not change on key UP" );\r
});\r
\r
-test("pageDown", function() {\r
- var el = $('#spin').spinner({\r
- step: 2,\r
- value: 0,\r
+test( "pageDown", function() {\r
+ expect( 4 );\r
+ var element = $( "#spin" ).spinner({\r
+ page: 20,\r
+ value: -12,\r
min: -100\r
});\r
\r
- el.spinner('pageDown');\r
- equals(el.val(), -20, "pageDown 1 page");\r
-\r
- el.spinner('pageDown', 3);\r
- equals(el.val(), -80, "pageDown 3 pages");\r
- \r
- el.val(-91).spinner('pageDown');\r
- equals(el.val(), -100, "value close to min and pageDown 1 page");\r
- \r
- el.spinner('pageDown', 10);\r
- equals(el.val(), -100, "value at min and pageDown 10 pages");\r
+ element.spinner( "pageDown" );\r
+ equals( element.val(), -32, "pageDown 1 page" );\r
+\r
+ element.spinner( "pageDown", 3 );\r
+ equals( element.val(), -92, "pageDown 3 pages" );\r
+\r
+ element.spinner( "pageDown" );\r
+ equals( element.val(), -100, "value close to min and pageDown 1 page" );\r
+\r
+ element.spinner( "pageDown", 10 );\r
+ equals( element.val(), -100, "value at min and pageDown 10 pages" );\r
});\r
\r
-test("pageUp", function() {\r
- var el = $('#spin').spinner({\r
- step: 2,\r
- value: 0,\r
+test( "pageUp", function() {\r
+ expect( 4 );\r
+ var element = $( "#spin" ).spinner({\r
+ page: 20,\r
+ value: 12,\r
max: 100\r
});\r
\r
- el.spinner('pageUp');\r
- equals(el.val(), 20, "pageUp 1 page");\r
+ element.spinner( "pageUp" );\r
+ equals( element.val(), 32, "pageUp 1 page" );\r
\r
- el.spinner('pageUp', 3);\r
- equals(el.val(), 80, "pageUp 3 pages");\r
+ element.spinner( "pageUp", 3 );\r
+ equals( element.val(), 92, "pageUp 3 pages" );\r
\r
- el.val(91).spinner('pageUp');\r
- equals(el.val(), 100, "value close to max and pageUp 1 page");\r
- \r
- el.spinner('pageUp', 10);\r
- equals(el.val(), 100, "value at max and pageUp 10 pages");\r
- \r
+ element.spinner( "pageUp" );\r
+ equals( element.val(), 100, "value close to max and pageUp 1 page" );\r
+\r
+ element.spinner( "pageUp", 10 );\r
+ equals( element.val(), 100, "value at max and pageUp 10 pages" );\r
});\r
\r
-test("stepDown", function() {\r
- expect(4);\r
+test( "stepDown", function() {\r
+ expect( 4 );\r
+ var element = $( "#spin" ).spinner({\r
+ step: 2,\r
+ value: 0,\r
+ min: -15\r
+ });\r
\r
- el = $('#spin').spinner({ step: 2, page: 5, value: 0, min: -15 });\r
+ element.spinner( "stepDown" );\r
+ equals( element.val(), -2, "stepDown 1 step" );\r
\r
- el.spinner('stepDown')\r
- equals(el.val(), -2, "stepDown 1 step");\r
+ element.spinner( "stepDown", 5 );\r
+ equals( element.val(), -12, "stepDown 5 steps" );\r
\r
- el.spinner('stepDown', 5)\r
- equals(el.val(), -12, "stepDown 5 steps");\r
- \r
- el.spinner('stepDown', 3);\r
- equals(el.val(), -15, "close to min and stepDown 3 steps");\r
+ element.spinner( "stepDown", 4 );\r
+ equals( element.val(), -15, "close to min and stepDown 4 steps" );\r
\r
- el.spinner('stepDown');\r
- equals(el.val(), -15, "at min and stepDown 1 step");\r
+ element.spinner( "stepDown" );\r
+ equals( element.val(), -15, "at min and stepDown 1 step" );\r
});\r
\r
-test("stepUp", function() {\r
- expect(4);\r
-\r
- el = $('#spin').spinner({ step: 2, page: 5, value: 0, max: 15 });\r
+test( "stepUp", function() {\r
+ expect( 4 );\r
+ var element = $( "#spin" ).spinner({\r
+ step: 2,\r
+ value: 0,\r
+ max: 15\r
+ });\r
\r
- el.spinner('stepUp')\r
- equals(el.val(), 2, "stepUp 1 steps");\r
+ element.spinner( "stepUp" );\r
+ equals( element.val(), 2, "stepUp 1 step" );\r
\r
- el.spinner('stepUp', 5)\r
- equals(el.val(), 12, "stepUp 5 steps");\r
- \r
- el.spinner('stepUp', 3);\r
- equals(el.val(), 15, "close to min and stepUp 3 steps");\r
+ element.spinner( "stepUp", 5 );\r
+ equals( element.val(), 12, "stepUp 5 steps" );\r
\r
- el.spinner('stepUp');\r
- equals(el.val(), 15, "at min and stepUp 1 step");\r
+ element.spinner( "stepUp", 4 );\r
+ equals( element.val(), 15, "close to min and stepUp 4 steps" );\r
\r
+ element.spinner( "stepUp" );\r
+ equals( element.val(), 15, "at max and stepUp 1 step" );\r
});\r
\r
-test("value", function() {\r
- expect(2);\r
- \r
- el = $('#spin').spinner({ value: 0 });\r
- \r
- el.spinner('value', 10);\r
- equals(el.val(), 10, "change value via value method");\r
- \r
- equals(10, el.spinner('value'), "get value via value method");\r
+test( "value", function() {\r
+ expect( 2 );\r
+ var element = $( "#spin" ).spinner({ value: 0 });\r
+\r
+ element.spinner( "value", 10 );\r
+ equals( element.val(), 10, "change value via value method" );\r
+\r
+ equals( element.spinner( "value" ), 10, "get value via value method" );\r
});\r
\r
-})(jQuery);\r
+})( jQuery );\r
-/*\r
- * spinner_options.js\r
- */\r
-(function($) {\r
+(function( $ ) {\r
\r
-module("spinner: options");\r
+module( "spinner: options" );\r
\r
-test("numberFormat, number", function() {\r
- var el = $("#spin").spinner({\r
+test( "numberFormat, number", function() {\r
+ expect( 1 );\r
+ var element = $( "#spin" ).spinner({\r
value: "1",\r
numberFormat: "n"\r
});\r
- equal(el.val(), "1.00");\r
+ equal( element.val(), "1.00", "n" );\r
});\r
\r
-test("numberFormat, number, simple", function() {\r
- var el = $("#spin").spinner({\r
+test( "numberFormat, number, simple", function() {\r
+ expect( 1 );\r
+ var element = $( "#spin" ).spinner({\r
value: "1",\r
numberFormat: "n0"\r
});\r
- equal(el.val(), "1");\r
+ equal( element.val(), "1", "n0" );\r
});\r
\r
-test("numberFormat, currency", function() {\r
- var el = $("#spin").spinner({\r
+test( "numberFormat, currency", function() {\r
+ expect( 1 );\r
+ var element = $( "#spin" ).spinner({\r
value: "1",\r
numberFormat: "C"\r
});\r
- equal(el.val(), "$1.00");\r
+ equal( element.val(), "$1.00", "C" );\r
});\r
\r
/* TODO figure out how to test this properly\r
});\r
*/\r
\r
-test("max", function() {\r
- var el = $("#spin").spinner({ max: 100, value: 1000 });\r
- equals(el.val(), 100, "max constrained if value option is greater");\r
- \r
- el.spinner('value', 1000);\r
- equals(el.val(), 100, "max constrained if value method is greater");\r
- \r
- el.val(1000).blur();\r
- equals(el.val(), 100, "max constrained if manual entry");\r
-});\r
+test( "max", function() {\r
+ expect( 3 );\r
+ var element = $( "#spin" ).spinner({ max: 100, value: 1000 });\r
+ equals( element.val(), 100, "max constrained if value option is greater" );\r
+\r
+ element.spinner( "value", 1000 );\r
+ equals( element.val(), 100, "max constrained if value method is greater" );\r
\r
-test("min", function() {\r
- var el = $("#spin").spinner({ min: -100, value: -1000 });\r
- equals(el.val(), -100, "min constrained if value option is greater");\r
- \r
- el.spinner('value', -1000);\r
- equals(el.val(), -100, "min constrained if value method is greater");\r
- \r
- el.val(-1000).blur();\r
- equals(el.val(), -100, "min constrained if manual entry");\r
+ element.val( 1000 ).blur();\r
+ equals( element.val(), 100, "max constrained if manual entry" );\r
});\r
\r
-test("step, 2", function() {\r
- var el = $("#spin").spinner({ step: 2 });\r
- equals(el.val(), "0", "value initialized to");\r
- \r
- for ( var i = 0 ; i < 5 ; i++ ) {\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);\r
- }\r
- equals(el.val(), "10", "UP 5 times with step: 2");\r
+test( "min", function() {\r
+ expect( 3 );\r
+ var element = $( "#spin" ).spinner({ min: -100, value: -1000 });\r
+ equals( element.val(), -100, "min constrained if value option is greater" );\r
\r
- el.spinner('value', '10.5');\r
- equals(el.val(), "10.5", "value reset to");\r
+ element.spinner( "value", -1000 );\r
+ equals( element.val(), -100, "min constrained if value method is greater" );\r
\r
- el.spinner('option', 'step', 2);\r
- for ( var i = 0 ; i < 5 ; i++ ) {\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);\r
- }\r
- equals(el.val(), "20.5", "UP 5 times with step: 2");\r
+ element.val( -1000 ).blur();\r
+ equals( element.val(), -100, "min constrained if manual entry" );\r
});\r
\r
-test("step, 0.7", function() {\r
- var el = $("#spin").spinner({\r
- step: 0.7,\r
- numberFormat: "n1"\r
- });\r
- equals(el.val(), "0.0", "value initialized to");\r
-\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.DOWN);\r
- equals(el.val(), "-0.7", "DOWN 1 time with step: 0.7");\r
+test( "step, 2", function() {\r
+ expect( 4 );\r
+ var element = $( "#spin" ).spinner({ step: 2 });\r
+ equals( element.val(), "0", "value initialized to 0" );\r
\r
- for ( var i = 0 ; i < 11 ; i++ ) {\r
- spinner_simulateKeyDownUp(el, $.ui.keyCode.UP);\r
- }\r
- equals(el.val(), "7.0", "UP 11 times with step: 0.7");\r
-});\r
+ element.spinner( "stepUp" );\r
+ equals( element.val(), "2", "stepUp" );\r
\r
-test("value, default, specified in markup", function() {\r
- var el = $('#spin2').spinner();\r
- equals(el.val(), 2, "starting value");\r
-});\r
+ element.spinner( "value", "10.5" );\r
+ equals( element.val(), "10.5", "value reset to 10.5" );\r
\r
-test("value, default, nothing specified", function() {\r
- var el = $('#spin').spinner();\r
- equals(el.val(), 0, "starting value");\r
+ element.spinner( "stepUp" );\r
+ equals( element.val(), "12.5", "stepUp" );\r
});\r
\r
-test("value, override", function() {\r
- var el = $('#spin').spinner({ value: 100 });\r
- equals(el.val(), 100, "starting value");\r
-});\r
+test( "step, 0.7", function() {\r
+ expect( 2 );\r
+ var element = $("#spin").spinner({\r
+ step: 0.7\r
+ });\r
+ equals( element.val(), "0", "value initialized to 0" );\r
\r
-test("value, override markup", function() {\r
- var el = $('#spin2').spinner({ value: 100 });\r
- equals(el.val(), 100, "starting value");\r
+ element.spinner( "stepUp" );\r
+ equals( element.val(), "0.7", "stepUp" );\r
});\r
\r
-test("value, override later", function() {\r
- var el = $('#spin').spinner();\r
- equals(el.val(), 0, "starting value");\r
- el.spinner('option', 'value', 1000);\r
- equals(el.val(), 1000, "value option changed and set as current value");\r
-});\r
+// TODO: test value\r
\r
-})(jQuery);\r
+})( jQuery );\r