From 6d0e27d2de7febbace7a61036dbdc3f9c33f6c1b Mon Sep 17 00:00:00 2001 From: Chi Cheng Date: Tue, 19 Aug 2008 17:58:57 +0000 Subject: [PATCH] Spinner test: up, down callback --- tests/spinner.js | 27 ++++++++++++++++++--------- 1 file 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"); - equals(s, 5, "Spin 5 times"); + 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(c, 2, "Change 2 times"); + equals(s, 3, "Spin 3 times"); + + el.simulate("keydown",{keyCode:$.simulate.VK_UP}).simulate("keyup",{keyCode:$.simulate.VK_UP}); + + equals(c, 4, "Change 4 times"); });