Skip to content
Permalink
Browse files

Spinner test: up, down callback

  • Loading branch information
chicheng committed Aug 19, 2008
1 parent 68f18e1 commit 6d0e27d2de7febbace7a61036dbdc3f9c33f6c1b
Showing with 18 additions and 9 deletions.
  1. +18 −9 tests/spinner.js
@@ -265,31 +265,40 @@ 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(){
s++;
},
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");

});

0 comments on commit 6d0e27d

Please sign in to comment.
You can’t perform that action at this time.