aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/spinner/spinner.html90
-rw-r--r--tests/unit/spinner/spinner_core.js302
-rw-r--r--tests/unit/spinner/spinner_defaults.js38
-rw-r--r--tests/unit/spinner/spinner_events.js100
-rw-r--r--tests/unit/spinner/spinner_methods.js318
-rw-r--r--tests/unit/spinner/spinner_options.js244
6 files changed, 546 insertions, 546 deletions
diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html
index 59185a441..8afa5fab8 100644
--- a/tests/unit/spinner/spinner.html
+++ b/tests/unit/spinner/spinner.html
@@ -1,45 +1,45 @@
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner Test Suite</title>
-
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css">
-
- <script src="../../jquery.js"></script>
- <script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
- <script src="../../../external/jquery.global.js"></script>
- <script src="../../../ui/jquery.ui.core.js"></script>
- <script src="../../../ui/jquery.ui.widget.js"></script>
- <script src="../../../ui/jquery.ui.button.js"></script>
- <script src="../../../ui/jquery.ui.spinner.js"></script>
-
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
-
- <script src="spinner_test_helpers.js"></script>
- <script src="spinner_core.js"></script>
- <script src="spinner_defaults.js"></script>
- <script src="spinner_events.js"></script>
- <script src="spinner_methods.js"></script>
- <script src="spinner_options.js"></script>
-
- <script src="../swarminject.js"></script>
-</head>
-<body>
-
-<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
-<h2 id="qunit-banner"></h2>
-<div id="qunit-testrunner-toolbar"></div>
-<h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests"></ol>
-<div id="qunit-fixture">
-
-<input id="spin" class="foo">
-<input id="spin2" value="2">
-
-</div>
-</body>
-</html>
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Spinner Test Suite</title>
+
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css">
+
+ <script src="../../jquery.js"></script>
+ <script src="../../../external/jquery.mousewheel-3.0.4.js"></script>
+ <script src="../../../external/jquery.global.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.button.js"></script>
+ <script src="../../../ui/jquery.ui.spinner.js"></script>
+
+ <link rel="stylesheet" href="../../../external/qunit.css">
+ <script src="../../../external/qunit.js"></script>
+ <script src="../../jquery.simulate.js"></script>
+ <script src="../testsuite.js"></script>
+
+ <script src="spinner_test_helpers.js"></script>
+ <script src="spinner_core.js"></script>
+ <script src="spinner_defaults.js"></script>
+ <script src="spinner_events.js"></script>
+ <script src="spinner_methods.js"></script>
+ <script src="spinner_options.js"></script>
+
+ <script src="../swarminject.js"></script>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests"></ol>
+<div id="qunit-fixture">
+
+<input id="spin" class="foo">
+<input id="spin2" value="2">
+
+</div>
+</body>
+</html>
diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js
index b05a6630f..dc8a44d88 100644
--- a/tests/unit/spinner/spinner_core.js
+++ b/tests/unit/spinner/spinner_core.js
@@ -1,151 +1,151 @@
-(function( $ ) {
-
-module( "spinner: core" );
-
-// TODO: move to spinner_methods
-test( "destroy", function() {
- expect( 1 );
- // TODO: is this cheat still needed?
- // cheat a bit to get IE6 to pass
- $( "#spin" ).val( 0 );
- domEqual( "#spin", function() {
- $( "#spin" ).spinner().spinner( "destroy" );
- });
-});
-
-test( "keydown UP on input, increases value not greater than max", function() {
- expect( 5 );
- var element = $( "#spin" ).spinner({
- max: 100,
- value: 70,
- step: 10
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( element.val(), 80 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( element.val(), 90 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( element.val(), 100 );
-});
-
-test( "keydown DOWN on input, decreases value not less than min", function() {
- expect( 5 );
- var element = $( "#spin" ).spinner({
- min: 20,
- value: 50,
- step: 10
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( element.val(), 40 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( element.val(), 30 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( element.val(), 20 );
-});
-
-test( "keydown PGUP on input, increases value not greater than max", function() {
- expect( 5 );
- var element = $( "#spin" ).spinner({
- max: 100,
- value: 70,
- page: 10
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( element.val(), 80 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( element.val(), 90 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( element.val(), 100 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( element.val(), 100 );
-});
-
-test( "keydown PGDN on input, decreases value not less than min", function() {
- expect( 5 );
- var element = $( "#spin" ).spinner({
- min: 20,
- value: 50,
- page: 10
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( element.val(), 40 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( element.val(), 30 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( element.val(), 20 );
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( element.val(), 20 );
-});
-
-test( "mouse click on buttons", function() {
- expect( 2 );
- var element = $( "#spin" ).spinner(),
- val = 0;
-
- $( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( element.val(), ++val, "mouse click on up" );
-
- $( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( element.val(), --val, "mouse click on down");
-});
-
-test( "mouse wheel on input", function() {
- expect( 4 );
-
- var element = $( "#spin" ).spinner();
- equal( element.val(), 0 );
- element.trigger( "mousewheel", 1 );
- equal( element.val(), 1 );
-
- element.trigger( "mousewheel", -1 );
- equal( element.val(), 0 );
-
- element.trigger( "mousewheel", -1 );
- equal(element.val(), -1 );
-});
-
-test( "reading HTML5 attributes", function() {
- expect( 4 );
- var element = $( "<input id='spinner' type='number' min='-100' max='100' value='5' step='2'>" ).spinner();
- equals( element.spinner( "option", "value" ), 5, "value" );
- equals( element.spinner( "option", "max" ), 100, "max" );
- equals( element.spinner( "option", "min" ), -100, "min" );
- equals( element.spinner( "option", "step" ), 2, "step" );
-});
-
-test( "ARIA attributes", function() {
- expect( 7 );
- var element = $( "#spin" ).spinner({ min: -5, max: 5, value: 2 });
-
- equals( element.attr( "role" ), "spinbutton", "role" );
- equals( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
- equals( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
- equals( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );
-
- element.spinner( "stepUp" );
-
- equals( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );
-
- element.spinner( "option", { min: -10, max: 10 } );
-
- equals( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
- equals( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
-});
-
-})( jQuery );
+(function( $ ) {
+
+module( "spinner: core" );
+
+// TODO: move to spinner_methods
+test( "destroy", function() {
+ expect( 1 );
+ // TODO: is this cheat still needed?
+ // cheat a bit to get IE6 to pass
+ $( "#spin" ).val( 0 );
+ domEqual( "#spin", function() {
+ $( "#spin" ).spinner().spinner( "destroy" );
+ });
+});
+
+test( "keydown UP on input, increases value not greater than max", function() {
+ expect( 5 );
+ var element = $( "#spin" ).spinner({
+ max: 100,
+ value: 70,
+ step: 10
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( element.val(), 80 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( element.val(), 90 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( element.val(), 100 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( element.val(), 100 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( element.val(), 100 );
+});
+
+test( "keydown DOWN on input, decreases value not less than min", function() {
+ expect( 5 );
+ var element = $( "#spin" ).spinner({
+ min: 20,
+ value: 50,
+ step: 10
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( element.val(), 40 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( element.val(), 30 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( element.val(), 20 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( element.val(), 20 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( element.val(), 20 );
+});
+
+test( "keydown PGUP on input, increases value not greater than max", function() {
+ expect( 5 );
+ var element = $( "#spin" ).spinner({
+ max: 100,
+ value: 70,
+ page: 10
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( element.val(), 80 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( element.val(), 90 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( element.val(), 100 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( element.val(), 100 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( element.val(), 100 );
+});
+
+test( "keydown PGDN on input, decreases value not less than min", function() {
+ expect( 5 );
+ var element = $( "#spin" ).spinner({
+ min: 20,
+ value: 50,
+ page: 10
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( element.val(), 40 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( element.val(), 30 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( element.val(), 20 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( element.val(), 20 );
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( element.val(), 20 );
+});
+
+test( "mouse click on buttons", function() {
+ expect( 2 );
+ var element = $( "#spin" ).spinner(),
+ val = 0;
+
+ $( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
+ equals( element.val(), ++val, "mouse click on up" );
+
+ $( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
+ equals( element.val(), --val, "mouse click on down");
+});
+
+test( "mouse wheel on input", function() {
+ expect( 4 );
+
+ var element = $( "#spin" ).spinner();
+ equal( element.val(), 0 );
+ element.trigger( "mousewheel", 1 );
+ equal( element.val(), 1 );
+
+ element.trigger( "mousewheel", -1 );
+ equal( element.val(), 0 );
+
+ element.trigger( "mousewheel", -1 );
+ equal(element.val(), -1 );
+});
+
+test( "reading HTML5 attributes", function() {
+ expect( 4 );
+ var element = $( "<input id='spinner' type='number' min='-100' max='100' value='5' step='2'>" ).spinner();
+ equals( element.spinner( "option", "value" ), 5, "value" );
+ equals( element.spinner( "option", "max" ), 100, "max" );
+ equals( element.spinner( "option", "min" ), -100, "min" );
+ equals( element.spinner( "option", "step" ), 2, "step" );
+});
+
+test( "ARIA attributes", function() {
+ expect( 7 );
+ var element = $( "#spin" ).spinner({ min: -5, max: 5, value: 2 });
+
+ equals( element.attr( "role" ), "spinbutton", "role" );
+ equals( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
+ equals( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
+ equals( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );
+
+ element.spinner( "stepUp" );
+
+ equals( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );
+
+ element.spinner( "option", { min: -10, max: 10 } );
+
+ equals( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
+ equals( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
+});
+
+})( jQuery );
diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js
index c4e9c7b6f..3a6287618 100644
--- a/tests/unit/spinner/spinner_defaults.js
+++ b/tests/unit/spinner/spinner_defaults.js
@@ -1,19 +1,19 @@
-commonWidgetTests( "spinner", {
- defaults: {
- disabled: false,
- incremental: true,
- max: Number.MAX_VALUE,
- min: -Number.MAX_VALUE,
- numberFormat: null,
- page: 10,
- step: 1,
- value: null,
-
- // callbacks
- change: null,
- create: null,
- spin: null,
- start: null,
- stop: null
- }
-});
+commonWidgetTests( "spinner", {
+ defaults: {
+ disabled: false,
+ incremental: true,
+ max: Number.MAX_VALUE,
+ min: -Number.MAX_VALUE,
+ numberFormat: null,
+ page: 10,
+ step: 1,
+ value: null,
+
+ // callbacks
+ change: null,
+ create: null,
+ spin: null,
+ start: null,
+ stop: null
+ }
+});
diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js
index 66735028a..98292b055 100644
--- a/tests/unit/spinner/spinner_events.js
+++ b/tests/unit/spinner/spinner_events.js
@@ -1,50 +1,50 @@
-(function( $ ) {
-
-module( "spinner: events" );
-
-test( "start", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- start: function() {
- ok( true, "start" );
- }
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
-});
-
-test( "spin", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- spin: function(){
- ok( true, "spin" );
- }
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
-});
-
-test( "stop", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- stop: function(){
- ok( true, "stop" );
- }
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
-});
-
-test( "change", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- change: function(){
- ok( true, "change" );
- }
- });
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- element.blur();
-});
-
-})( jQuery );
+(function( $ ) {
+
+module( "spinner: events" );
+
+test( "start", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ start: function() {
+ ok( true, "start" );
+ }
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+});
+
+test( "spin", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ spin: function(){
+ ok( true, "spin" );
+ }
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+});
+
+test( "stop", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ stop: function(){
+ ok( true, "stop" );
+ }
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+});
+
+test( "change", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ change: function(){
+ ok( true, "change" );
+ }
+ });
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ element.blur();
+});
+
+})( jQuery );
diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js
index 4839844c9..e12432a76 100644
--- a/tests/unit/spinner/spinner_methods.js
+++ b/tests/unit/spinner/spinner_methods.js
@@ -1,159 +1,159 @@
-(function( $ ) {
-
-module( "spinner: methods" );
-
-test( "disable", function() {
- expect( 14 );
- var element = $( "#spin" ).spinner({ value: 2 }),
- wrapper = $( "#spin" ).spinner( "widget" );
-
- ok( !wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper does not have ui-spinner-disabled class" );
- ok( !element.is( ":disabled" ), "before: input does not have disabled attribute" );
-
- element.spinner( "disable" );
- ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" );
- ok( element.is( ":disabled"), "after: input has disabled attribute" );
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( 2, element.val(), "keyboard - value does not change on key UP" );
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( 2, element.val(), "keyboard - value does not change on key DOWN" );
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( 2, element.val(), "keyboard - value does not change on key PGUP" );
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( 2, element.val(), "keyboard - value does not change on key PGDN" );
-
- wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( 2, element.val(), "mouse - value does not change on clicking up button" );
-
- wrapper.find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( 2, element.val(), "mouse - value does not change on clicking down button" );
-
- element.spinner( "stepUp", 6 );
- equals( 8, element.val(), "script - stepUp 6 steps changes value");
-
- element.spinner( "stepDown" );
- equals( 7, element.val(), "script - stepDown 1 step changes value" );
-
- element.spinner( "pageUp" );
- equals( 17, element.val(), "script - pageUp 1 page changes value" );
-
- element.spinner( "pageDown" );
- equals( 7, element.val(), "script - pageDown 1 page changes value" );
-});
-
-test( "enable", function() {
- expect( 5 );
- var element = $( "#spin" ).spinner({ disabled: true })
- wrapper = element.spinner( "widget" );
-
- ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );
- ok( element.is( ":disabled" ), "before: input has disabled attribute" );
-
- element.spinner( "enable" );
-
- ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" );
- ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );
-
- spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( 1, element.val(), "keyboard - value does not change on key UP" );
-});
-
-test( "pageDown", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({
- page: 20,
- value: -12,
- min: -100
- });
-
- element.spinner( "pageDown" );
- equals( element.val(), -32, "pageDown 1 page" );
-
- element.spinner( "pageDown", 3 );
- equals( element.val(), -92, "pageDown 3 pages" );
-
- element.spinner( "pageDown" );
- equals( element.val(), -100, "value close to min and pageDown 1 page" );
-
- element.spinner( "pageDown", 10 );
- equals( element.val(), -100, "value at min and pageDown 10 pages" );
-});
-
-test( "pageUp", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({
- page: 20,
- value: 12,
- max: 100
- });
-
- element.spinner( "pageUp" );
- equals( element.val(), 32, "pageUp 1 page" );
-
- element.spinner( "pageUp", 3 );
- equals( element.val(), 92, "pageUp 3 pages" );
-
- element.spinner( "pageUp" );
- equals( element.val(), 100, "value close to max and pageUp 1 page" );
-
- element.spinner( "pageUp", 10 );
- equals( element.val(), 100, "value at max and pageUp 10 pages" );
-});
-
-test( "stepDown", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({
- step: 2,
- value: 0,
- min: -15
- });
-
- element.spinner( "stepDown" );
- equals( element.val(), -2, "stepDown 1 step" );
-
- element.spinner( "stepDown", 5 );
- equals( element.val(), -12, "stepDown 5 steps" );
-
- element.spinner( "stepDown", 4 );
- equals( element.val(), -15, "close to min and stepDown 4 steps" );
-
- element.spinner( "stepDown" );
- equals( element.val(), -15, "at min and stepDown 1 step" );
-});
-
-test( "stepUp", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({
- step: 2,
- value: 0,
- max: 15
- });
-
- element.spinner( "stepUp" );
- equals( element.val(), 2, "stepUp 1 step" );
-
- element.spinner( "stepUp", 5 );
- equals( element.val(), 12, "stepUp 5 steps" );
-
- element.spinner( "stepUp", 4 );
- equals( element.val(), 15, "close to min and stepUp 4 steps" );
-
- element.spinner( "stepUp" );
- equals( element.val(), 15, "at max and stepUp 1 step" );
-});
-
-test( "value", function() {
- expect( 2 );
- var element = $( "#spin" ).spinner({ value: 0 });
-
- element.spinner( "value", 10 );
- equals( element.val(), 10, "change value via value method" );
-
- equals( element.spinner( "value" ), 10, "get value via value method" );
-});
-
-})( jQuery );
+(function( $ ) {
+
+module( "spinner: methods" );
+
+test( "disable", function() {
+ expect( 14 );
+ var element = $( "#spin" ).spinner({ value: 2 }),
+ wrapper = $( "#spin" ).spinner( "widget" );
+
+ ok( !wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper does not have ui-spinner-disabled class" );
+ ok( !element.is( ":disabled" ), "before: input does not have disabled attribute" );
+
+ element.spinner( "disable" );
+ ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" );
+ ok( element.is( ":disabled"), "after: input has disabled attribute" );
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( 2, element.val(), "keyboard - value does not change on key UP" );
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
+ equals( 2, element.val(), "keyboard - value does not change on key DOWN" );
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
+ equals( 2, element.val(), "keyboard - value does not change on key PGUP" );
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
+ equals( 2, element.val(), "keyboard - value does not change on key PGDN" );
+
+ wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
+ equals( 2, element.val(), "mouse - value does not change on clicking up button" );
+
+ wrapper.find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
+ equals( 2, element.val(), "mouse - value does not change on clicking down button" );
+
+ element.spinner( "stepUp", 6 );
+ equals( 8, element.val(), "script - stepUp 6 steps changes value");
+
+ element.spinner( "stepDown" );
+ equals( 7, element.val(), "script - stepDown 1 step changes value" );
+
+ element.spinner( "pageUp" );
+ equals( 17, element.val(), "script - pageUp 1 page changes value" );
+
+ element.spinner( "pageDown" );
+ equals( 7, element.val(), "script - pageDown 1 page changes value" );
+});
+
+test( "enable", function() {
+ expect( 5 );
+ var element = $( "#spin" ).spinner({ disabled: true })
+ wrapper = element.spinner( "widget" );
+
+ ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );
+ ok( element.is( ":disabled" ), "before: input has disabled attribute" );
+
+ element.spinner( "enable" );
+
+ ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" );
+ ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );
+
+ spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
+ equals( 1, element.val(), "keyboard - value does not change on key UP" );
+});
+
+test( "pageDown", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({
+ page: 20,
+ value: -12,
+ min: -100
+ });
+
+ element.spinner( "pageDown" );
+ equals( element.val(), -32, "pageDown 1 page" );
+
+ element.spinner( "pageDown", 3 );
+ equals( element.val(), -92, "pageDown 3 pages" );
+
+ element.spinner( "pageDown" );
+ equals( element.val(), -100, "value close to min and pageDown 1 page" );
+
+ element.spinner( "pageDown", 10 );
+ equals( element.val(), -100, "value at min and pageDown 10 pages" );
+});
+
+test( "pageUp", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({
+ page: 20,
+ value: 12,
+ max: 100
+ });
+
+ element.spinner( "pageUp" );
+ equals( element.val(), 32, "pageUp 1 page" );
+
+ element.spinner( "pageUp", 3 );
+ equals( element.val(), 92, "pageUp 3 pages" );
+
+ element.spinner( "pageUp" );
+ equals( element.val(), 100, "value close to max and pageUp 1 page" );
+
+ element.spinner( "pageUp", 10 );
+ equals( element.val(), 100, "value at max and pageUp 10 pages" );
+});
+
+test( "stepDown", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({
+ step: 2,
+ value: 0,
+ min: -15
+ });
+
+ element.spinner( "stepDown" );
+ equals( element.val(), -2, "stepDown 1 step" );
+
+ element.spinner( "stepDown", 5 );
+ equals( element.val(), -12, "stepDown 5 steps" );
+
+ element.spinner( "stepDown", 4 );
+ equals( element.val(), -15, "close to min and stepDown 4 steps" );
+
+ element.spinner( "stepDown" );
+ equals( element.val(), -15, "at min and stepDown 1 step" );
+});
+
+test( "stepUp", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({
+ step: 2,
+ value: 0,
+ max: 15
+ });
+
+ element.spinner( "stepUp" );
+ equals( element.val(), 2, "stepUp 1 step" );
+
+ element.spinner( "stepUp", 5 );
+ equals( element.val(), 12, "stepUp 5 steps" );
+
+ element.spinner( "stepUp", 4 );
+ equals( element.val(), 15, "close to min and stepUp 4 steps" );
+
+ element.spinner( "stepUp" );
+ equals( element.val(), 15, "at max and stepUp 1 step" );
+});
+
+test( "value", function() {
+ expect( 2 );
+ var element = $( "#spin" ).spinner({ value: 0 });
+
+ element.spinner( "value", 10 );
+ equals( element.val(), 10, "change value via value method" );
+
+ equals( element.spinner( "value" ), 10, "get value via value method" );
+});
+
+})( jQuery );
diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js
index 33a7c1978..30155e755 100644
--- a/tests/unit/spinner/spinner_options.js
+++ b/tests/unit/spinner/spinner_options.js
@@ -1,122 +1,122 @@
-(function( $ ) {
-
-module( "spinner: options" );
-
-test( "numberFormat, number", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "n"
- });
- equal( element.val(), "1.00", "n" );
-});
-
-test( "numberFormat, number, simple", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "n0"
- });
- equal( element.val(), "1", "n0" );
-});
-
-test( "numberFormat, currency", function() {
- expect( 1 );
- var element = $( "#spin" ).spinner({
- value: "1",
- numberFormat: "C"
- });
- equal( element.val(), "$1.00", "C" );
-});
-
-/* TODO figure out how to test this properly
-test("incremental - false (default)", function() {
- var el = $("#spin").spinner({ incremental:false });
-
- for ( var i = 1 ; i<=120 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
-
- equals(el.val(), 120, "incremental false - keydown 120 times");
-
- for ( var i = 1 ; i<=210 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
-
- equals(el.val(), -90, "incremental false - keydown 210 times");
-});
-
-test("incremental - true (default)", function() {
- var el = $("#spin").spinner();
-
- for ( var i = 1 ; i<=120 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
-
- equals(el.val(), 300, "incremental true - keydown 120 times (100+20*10)");
-
- for ( var i = 1 ; i<=210 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
-
- equals(el.val(), -1800, "incremental true - keydown 210 times (300-100-100*10-10*100)");
-});
-*/
-
-test( "max", function() {
- expect( 3 );
- var element = $( "#spin" ).spinner({ max: 100, value: 1000 });
- equals( element.val(), 100, "max constrained if value option is greater" );
-
- 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" );
-});
-
-test( "min", function() {
- expect( 3 );
- var element = $( "#spin" ).spinner({ min: -100, value: -1000 });
- equals( element.val(), -100, "min constrained if value option is greater" );
-
- 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" );
-});
-
-test( "step, 2", function() {
- expect( 4 );
- var element = $( "#spin" ).spinner({ step: 2 });
- equals( element.val(), "0", "value initialized to 0" );
-
- element.spinner( "stepUp" );
- equals( element.val(), "2", "stepUp" );
-
- element.spinner( "value", "10.5" );
- equals( element.val(), "10.5", "value reset to 10.5" );
-
- element.spinner( "stepUp" );
- equals( element.val(), "12.5", "stepUp" );
-});
-
-test( "step, 0.7", function() {
- expect( 2 );
- var element = $("#spin").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 );
+(function( $ ) {
+
+module( "spinner: options" );
+
+test( "numberFormat, number", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ value: "1",
+ numberFormat: "n"
+ });
+ equal( element.val(), "1.00", "n" );
+});
+
+test( "numberFormat, number, simple", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ value: "1",
+ numberFormat: "n0"
+ });
+ equal( element.val(), "1", "n0" );
+});
+
+test( "numberFormat, currency", function() {
+ expect( 1 );
+ var element = $( "#spin" ).spinner({
+ value: "1",
+ numberFormat: "C"
+ });
+ equal( element.val(), "$1.00", "C" );
+});
+
+/* TODO figure out how to test this properly
+test("incremental - false (default)", function() {
+ var el = $("#spin").spinner({ incremental:false });
+
+ for ( var i = 1 ; i<=120 ; i++ ) {
+ el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
+ }
+ el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
+
+ equals(el.val(), 120, "incremental false - keydown 120 times");
+
+ for ( var i = 1 ; i<=210 ; i++ ) {
+ el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
+ }
+ el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
+
+ equals(el.val(), -90, "incremental false - keydown 210 times");
+});
+
+test("incremental - true (default)", function() {
+ var el = $("#spin").spinner();
+
+ for ( var i = 1 ; i<=120 ; i++ ) {
+ el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
+ }
+ el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
+
+ equals(el.val(), 300, "incremental true - keydown 120 times (100+20*10)");
+
+ for ( var i = 1 ; i<=210 ; i++ ) {
+ el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
+ }
+ el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
+
+ equals(el.val(), -1800, "incremental true - keydown 210 times (300-100-100*10-10*100)");
+});
+*/
+
+test( "max", function() {
+ expect( 3 );
+ var element = $( "#spin" ).spinner({ max: 100, value: 1000 });
+ equals( element.val(), 100, "max constrained if value option is greater" );
+
+ 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" );
+});
+
+test( "min", function() {
+ expect( 3 );
+ var element = $( "#spin" ).spinner({ min: -100, value: -1000 });
+ equals( element.val(), -100, "min constrained if value option is greater" );
+
+ 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" );
+});
+
+test( "step, 2", function() {
+ expect( 4 );
+ var element = $( "#spin" ).spinner({ step: 2 });
+ equals( element.val(), "0", "value initialized to 0" );
+
+ element.spinner( "stepUp" );
+ equals( element.val(), "2", "stepUp" );
+
+ element.spinner( "value", "10.5" );
+ equals( element.val(), "10.5", "value reset to 10.5" );
+
+ element.spinner( "stepUp" );
+ equals( element.val(), "12.5", "stepUp" );
+});
+
+test( "step, 0.7", function() {
+ expect( 2 );
+ var element = $("#spin").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 );