diff options
author | Chi Cheng <cloudream@gmail.com> | 2008-08-19 17:58:57 +0000 |
---|---|---|
committer | Chi Cheng <cloudream@gmail.com> | 2008-08-19 17:58:57 +0000 |
commit | 6d0e27d2de7febbace7a61036dbdc3f9c33f6c1b (patch) | |
tree | 6e1418fd211bbbe32ec04486cdd08970cf203f73 /tests | |
parent | 68f18e1c2dcfdc1386420e3335af7f99e7f2d205 (diff) | |
download | jquery-ui-6d0e27d2de7febbace7a61036dbdc3f9c33f6c1b.tar.gz jquery-ui-6d0e27d2de7febbace7a61036dbdc3f9c33f6c1b.zip |
Spinner test: up, down callback
Diffstat (limited to 'tests')
-rw-r--r-- | tests/spinner.js | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/spinner.js b/tests/spinner.js index 190da10a1..8458e0152 100644 --- a/tests/spinner.js +++ b/tests/spinner.js @@ -265,10 +265,9 @@ test("mouse click on buttons", function() { });
test("callback", function() {
- expect(2);
+ expect(4);
- var s = 0,
- c = 0;
+ var s = c = d = u = 0;
el = $("#spin").spinner({
spin: function(){
@@ -276,20 +275,30 @@ test("callback", function() { },
change: function(){
c++;
+ },
+ up: function(){
+ u++;
+ },
+ down: function(){
+ d++;
}
});
- for ( var i = 1 ; i<=5 ; i++ ) {
- el.simulate("keydown",{keyCode:$.simulate.VK_UP});
- }
+ el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP});
- el.simulate("keyup",{keyCode:$.simulate.VK_UP});
+ equals(u, 1, "Up 1 time");
+
+ el.simulate("keydown",{keyCode:$.simulate.VK_DOWN}).simulate("keyup",{keyCode:$.simulate.VK_DOWN});
+
+ equals(d, 1, "Down 1 time");
+
+ el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP});
- equals(s, 5, "Spin 5 times");
+ equals(s, 3, "Spin 3 times");
el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP});
- equals(c, 2, "Change 2 times");
+ equals(c, 4, "Change 4 times");
});
|