r3121 committed - spinner: added more unit tests to spinner_options.js

r3121 committed - spinner: added more unit tests to spinner_options.js


Revision: 3121
Author: pazu2k@gmail.com
Date: Sun Aug 23 21:18:19 2009
Log: spinner: added more unit tests to spinner_options.js
http://code.google.com/p/jquery-ui/source/detail?r=3121
Modified:
/branches/dev/spinner/tests/unit/spinner/spinner.html
/branches/dev/spinner/tests/unit/spinner/spinner_options.js
=======================================
--- /branches/dev/spinner/tests/unit/spinner/spinner.html    Sun Aug 23
20:10:11 2009
+++ /branches/dev/spinner/tests/unit/spinner/spinner.html    Sun Aug 23
21:18:19 2009
@@ -4,6 +4,7 @@
    <title>jQuery UI Spinner Test Suite</title>
    <script type="text/javascript" src="../../../jquery-1.3.2.js"></script>
+    <script type="text/javascript"
src="../../../external/mousewheel/jquery.mousewheel.min.js"></script>
    <script type="text/javascript" src="../../../ui/ui.core.js"></script>
    <script type="text/javascript" src="../../../ui/ui.spinner.js"></script>
=======================================
--- /branches/dev/spinner/tests/unit/spinner/spinner_options.js    Sun Aug 23
20:10:11 2009
+++ /branches/dev/spinner/tests/unit/spinner/spinner_options.js    Sun Aug 23
21:18:19 2009
@@ -277,11 +277,6 @@
    equals(el.val(), -1800, "incremental true - keydown 210 times
(300-100-100*10-10*100)");
});
-
-test("items", function() {
-    ok(false, 'missing test - untested code is broken code');
-});
-
test("max", function() {
    expect(3);
@@ -313,7 +308,11 @@
});
test("padding", function() {
-    ok(false, 'missing test - untested code is broken code');
+    expect(1);
+
+    el = $('#spin').spinner({ padding: 5, value: 10 });
+
+    equals(el.val(), '00010', 'padded output')
});
test("page", function() {
@@ -335,19 +334,66 @@
});
test("precision", function() {
-    ok(false, 'missing test - untested code is broken code');
+    expect(2);
+
+    el = $("#spin").spinner({ precision: 2, value: 1.23456789 });
+
+    equals(el.val(), '1.23', "2 decimal places");
+
+    el.spinner('option', 'precision', 4);
+
+    equals(el.val(), '1.2345', "4 decimal places");
});
test("radix", function() {
-    ok(false, 'missing test - untested code is broken code');
+    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() {
-    ok(false, 'missing test - untested code is broken code');
+    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("readOnly", function() {
-    ok(false, 'missing test - untested code is broken code');
+    expect(3);
+
+    el = $('#spin').spinner({ readOnly: true, value: 0 });
+
+    upButton().trigger('mousedown').trigger('mouseup');
+
+    equals(el.val(), 0, 'click on up button value un-changed');
+
+    simulateKeyDownUp(el, $.ui.keyCode.UP);
+
+    equals(el.val(), 0, 'key UP on spinner value un-changed');
+
+    el.spinner('stepUp');
+
+    equals(el.val(), 0, 'stepUp on spinner value un-changed');
});
test("spinnerClass", function() {