diff options
author | Chi Cheng <cloudream@gmail.com> | 2008-08-19 06:07:56 +0000 |
---|---|---|
committer | Chi Cheng <cloudream@gmail.com> | 2008-08-19 06:07:56 +0000 |
commit | 2ac541d500f4e92452a2195483c3f118a5ac4a32 (patch) | |
tree | 292536f79b12786de13df8804e252e116c07e3a0 /tests | |
parent | 1f6a9c9eda1cf26838cf3e7edf14830c7311ad1e (diff) | |
download | jquery-ui-2ac541d500f4e92452a2195483c3f118a5ac4a32.tar.gz jquery-ui-2ac541d500f4e92452a2195483c3f118a5ac4a32.zip |
Spinner test: callback
Diffstat (limited to 'tests')
-rw-r--r-- | tests/spinner.js | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/spinner.js b/tests/spinner.js index 4c0bf2b14..76ecee408 100644 --- a/tests/spinner.js +++ b/tests/spinner.js @@ -115,15 +115,15 @@ test("spin with auto-incremental stepping", function() { el.simulate("keyup",{keyCode:$.simulate.VK_UP});
- equals(el.val(), 300, "keydown 120 times");
+ equals(el.val(), 300, "keydown 120 times (100+20*10)");
- for ( var i = 1 ; i<=130 ; i++ ) {
+ for ( var i = 1 ; i<=210 ; i++ ) {
el.simulate("keydown",{keyCode:$.simulate.VK_DOWN});
}
el.simulate("keyup",{keyCode:$.simulate.VK_DOWN});
- equals(el.val(), -100, "keydown 130 times");
+ equals(el.val(), -1800, "keydown 210 times (300-100-100*10-10*100)");
});
@@ -150,6 +150,35 @@ test("mouse click on buttons", function() { });
+test("callback", function() {
+ expect(2);
+
+ var s = 0,
+ c = 0;
+
+ el = $("#spin").spinner({
+ spin: function(){
+ s++;
+ },
+ change: function(){
+ c++;
+ }
+ });
+
+ for ( var i = 1 ; i<=10 ; i++ ) {
+ el.simulate("keydown",{keyCode:$.simulate.VK_UP});
+ }
+
+ el.simulate("keyup",{keyCode:$.simulate.VK_UP});
+
+ equals(s, 10, "Spin 10 times");
+
+ el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP});
+
+ equals(c, 2, "Change 2 times");
+
+});
+
test("mouse wheel on input", function() {
expect(0);
|