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