diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index 7eb3f0a17..a85891970 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -11,7 +11,6 @@ var spinner_defaults = { mouseWheel: true, numberformat: "n", page: 5, - spinnerClass: null, step: null, value: 0 }; diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index c3bcac820..4e280ef6a 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -5,197 +5,8 @@ module("spinner: options"); -test("buttons - show (default)", function() { - expect(4); - - el = $('#spin'); - el.spinner({ - buttons: 'show' - }); - - ok(upButton().is(':visible'), "show - before hover: up button visible"); - ok(downButton().is(':visible'), "show - before hover: down button visible"); - - el.trigger('mouseover'); - - ok(upButton().is(':visible'), "show - after hover: up button visible"); - ok(downButton().is(':visible'), "show - after hover: down button visible"); - - el.trigger('mouseout'); -}); - -test("buttons - hide", function() { - expect(4); - - el = $('#spin'); - el.spinner({ - buttons: 'hide' - }); - - ok(upButton().is(':hidden'), "hide - before hover: up button hidden"); - ok(downButton().is(':hidden'), "hide - before hover: down button hidden"); - - el.trigger('mouseover'); - - ok(upButton().is(':hidden'), "hide - after hover: up button hidden"); - ok(downButton().is(':hidden'), "hide - after hover: down button hidden"); - - el.trigger('mouseout'); -}); - -test("buttons - auto (hover)", function() { - expect(4); - - el = $('#spin'); - el.spinner({ - buttons: 'auto' - }); - - ok(upButton().is(':hidden'), "auto - before hover: up button hidden"); - ok(downButton().is(':hidden'), "auto - before hover: down button hidden"); - - el.trigger('mouseover'); - - ok(upButton().is(':visible'), "auto - after hover: up button visible"); - ok(downButton().is(':visible'), "auto - after hover: down button visible"); - - el.trigger('mouseout'); -}); - -test("buttons - auto (focus)", function() { - expect(4); - - el = $('#spin'); - el.spinner({ - buttons: 'auto' - }); - - ok(upButton().is(':hidden'), "auto - before focus: up button hidden"); - ok(downButton().is(':hidden'), "auto - before focus: down button hidden"); - - el.focus(); - - ok(upButton().is(':visible'), "auto - after focus: up button visible"); - ok(downButton().is(':visible'), "auto - after focus: down button visible"); - - el.trigger('mouseout'); -}); - -test("currency - single character currency symbol", function() { - expect(5); - - el = $("#spin"); - - options = { - currency:"$", - max:120, - min:-50, - step:0.3 - }; - - el.spinner(options); - - equals(el.val(), "$0.00", "start number"); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), "$0.30", "stepping 0.30"); - - simulateKeyDownUp(el, $.ui.keyCode.END); - - equals(el.val(), "$120.00", "End key to max"); - - simulateKeyDownUp(el, $.ui.keyCode.HOME); - - equals(el.val(), "-$50.00", "Home key to min"); - - for ( var i = 1 ; i<=120 ; i++ ) { - simulateKeyDownUp(el, $.ui.keyCode.UP); - } - - equals(el.val(), "-$14.00", "keydown 120 times"); -}); - -test("currency - combined character currency symbol", function() { - expect(2); - - el = $('#spin'); - - options = { - currency: 'HK$', - step: 1500.50, - value: 1000 - } - - el.spinner(options); - - equals(el.val(), "HK$1,000.00", "Hong Kong Dollar"); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), "HK$2,500.50", "Hong Kong Dollar step-up once"); -}); - -test("currency - space as group separator", function() { - expect(2); - - el = $('#spin'); - - options = { - currency: '$', - groupSeparator: ' ', - radixPoint: '.', - step: 1500.50, - value: 1000 - } - - el.spinner(options); - - equals(el.val(), "$1 000.00", "Australian Dollar"); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), "$2 500.50", "Australian Dollar step-up once"); -}); - -test("currency - apos as group separator", function() { - expect(2); - - el = $('#spin'); - options = { - currency: 'Fr ', - groupSeparator: "'", - radixPoint: '.', - step: 1500.50, - value: 1000 - } - el.spinner(options); - - equals(el.val(), "Fr 1'000.00", "Swiss Franc"); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), "Fr 2'500.50", "Swiss Franc step-up once"); -}); - -test("currency - period as group separator and comma as radixPoint", function() { - expect(2); - - el = $('#spin'); - options = { - currency: 'RUB', - groupSeparator: ".", - radixPoint: ',', - step: 1.5, - value: 1000 - } - el.spinner(options); - - equals(el.val(), "RUB1.000,00", "Russian Ruble"); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), "RUB1.001,50", "Russian Ruble step-up once"); +test("numberformat", function() { + ok( false, "tests for numberformat!"); }); test("dir - left-to-right (default)", function() { @@ -220,42 +31,6 @@ test("dir - right-to-left", function() { ok(wrapper().hasClass('ui-spinner-rtl'), 'container has correct text direction class setting'); }); -test("groupSeparator - comma separator (default)", function() { - expect(1); - - el = $('#spin'); - options = { - groupSeparator: ',', - value: 1000000 - }; - el.spinner(options); - equals(el.val(), "1,000,000", "value contains 2 commas separated by 3 digits"); -}); - -test("groupSeparator - space separator", function() { - expect(1); - - el = $('#spin'); - options = { - groupSeparator: ' ', - value: 1000000 - }; - el.spinner(options); - equals(el.val(), "1 000 000", "value contains 2 spaces separated by 3 digits"); -}); - -test("groupSeparator - apos separator", function() { - expect(1); - - el = $('#spin'); - options = { - groupSeparator: "'", - value: 1000000 - }; - el.spinner(options); - equals(el.val(), "1'000'000", "value contains apos separated by 3 digits"); -}); - test("incremental - false (default)", function() { expect(2); @@ -326,20 +101,6 @@ test("mouseWheel", function() { ok(false, 'missing test - untested code is broken code'); }); -test("padding", function() { - expect(3); - - el = $('#spin').spinner({ padding: 5, value: 10 }); - - equals(el.val(), '00010', 'padded output'); - - el.spinner('option', 'padding', 4); - equals(el.val(), '0010', 'padded output'); - - el.spinner('value', 15); - equals(el.val(), '0015', 'padded output'); -}); - test("page", function() { expect(3); @@ -358,66 +119,6 @@ test("page", function() { equals(el.val(), "50", "PAGE_UP 11 times on spinner"); }); -test("precision", function() { - expect(3); - - el = $("#spin").spinner({ precision: 4, value: 1.23456789 }); - - equals(el.val(), '1.2346', "4 decimal places"); - - el.spinner('option', 'precision', 2); - - equals(el.val(), '1.23', "2 decimal places"); - - el.spinner('option', 'precision', 6); - - equals(el.val(), '1.234568', "6 decimal places"); -}); - -test("radix", function() { - expect(2); - - el = $("#spin").spinner({ - radix: 16, - value: 10 - }); - - equals(el.val(), 'a', 'start value'); - - simulateKeyDownUp(el, $.ui.keyCode.UP); - - equals(el.val(), 'b', 'key UP on spinner') -}); - -test("radixPoint", function() { - el = $("#spin").spinner({ - radixPoint: ',', - value: 20.00, - precision: 2 - }); - - equals(el.val(), '20,00', 'comma radix point'); - - el.spinner('stepUp'); - - equals(el.val(), '21,00', 'step up one'); - - el.spinner('pageDown', 10); - - equals(el.val(), '-29,00', 'page down into negative space'); -}); - -test("spinnerClass", function() { - expect(3); - - el = $('#spin').spinner({spinnerClass: 'my-spinner-class'}); - ok(wrapper().hasClass('my-spinner-class'), 'spinner container has custom class'); - - el.spinner('option', 'spinnerClass', 'new-spinner-class'); - ok(!wrapper().hasClass('my-spinner-class'), 'spinner no longer has old custom class'); - ok(wrapper().hasClass('new-spinner-class'), 'spinner now has new custom class'); -}); - test("step", function() { expect(7); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 02bb41ac0..a9238a738 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -28,7 +28,6 @@ $.widget('ui.spinner', { mouseWheel: true, numberformat: "n", page: 5, - spinnerClass: null, step: null, value: 0 }, @@ -141,10 +140,7 @@ $.widget('ui.spinner', { self.uiSpinner = uiSpinner; }, _uiSpinnerHtml: function() { - return '
'; + return '
'; }, _buttonHtml: function() { return '