diff options
author | jzaefferer <joern.zaefferer@gmail.com> | 2010-03-27 01:44:14 +0100 |
---|---|---|
committer | jzaefferer <joern.zaefferer@gmail.com> | 2010-03-27 01:44:14 +0100 |
commit | 3eee15fca88215446f5036e8fc2c965f5345a3c2 (patch) | |
tree | ff87d9ce41a58354fc51183ddcecbbf8ed2bf2e3 /tests/unit/slider/slider_events.js | |
parent | 885fea1f3d458ee884be0b20af03f2fbe362cc8b (diff) | |
download | jquery-ui-3eee15fca88215446f5036e8fc2c965f5345a3c2.tar.gz jquery-ui-3eee15fca88215446f5036e8fc2c965f5345a3c2.zip |
Slider tests: Split three different change-event tests into three tests, adding start, slide and stop assertions to each, removing placeholders for those other events
Diffstat (limited to 'tests/unit/slider/slider_events.js')
-rw-r--r-- | tests/unit/slider/slider_events.js | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js index fb9af8155..d7c146d84 100644 --- a/tests/unit/slider/slider_events.js +++ b/tests/unit/slider/slider_events.js @@ -3,45 +3,54 @@ */ (function($) { -var el; - module( "slider: events" ); -test( "start", function() { - ok( false, "missing test - untested code is broken code." ); -}); - -test( "slide", function() { - ok( false, "missing test - untested code is broken code." ); -}); - //Specs from http://wiki.jqueryui.com/Slider#specs //"change callback: triggers when the slider has stopped moving and has a new // value (even if same as previous value), via mouse(mouseup) or keyboard(keyup) // or value method/option" -test( "change", function() { - expect(8); +test( "mouse based interaction", function() { + expect(4); - var handle; - // Test mouseup at end of handle slide (mouse) - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .appendTo( "body" ) .slider({ + start: function(event, ui) { + equals( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); + }, + slide: function(event, ui) { + equals( event.originalEvent.type, "mousemove", "slider triggered by mousemove" ); + }, + stop: function(event, ui) { + equals( event.originalEvent.type, "mouseup", "stop triggered by mouseup" ); + }, change: function(event, ui) { - ok( true, "change triggered by mouseup at end of handle slide (mouse)" ); + equals( event.originalEvent.type, "mouseup", "change triggered by mouseup" ); } }); el.find( ".ui-slider-handle" ).eq( 0 ) .simulate( "drag", { dx: 10, dy: 10 } ); - reset(); +}); +test( "keyboard based interaction", function() { + expect(3); + // Test keyup at end of handle slide (keyboard) - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .appendTo( "body" ) .slider({ + start: function(event, ui) { + equals( event.originalEvent.type, "keydown", "start triggered by keydown" ); + }, + slide: function(event, ui) { + ok( false, "Slider never triggered by keys" ); + }, + stop: function(event, ui) { + equals( event.originalEvent.type, "keyup", "stop triggered by keyup" ); + }, change: function(event, ui) { - ok( true, "change triggered by keyup at end of handle slide (keyboard)" ); + equals( event.originalEvent.type, "keyup", "change triggered by keyup" ); } }); @@ -50,9 +59,12 @@ test( "change", function() { .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } ) .simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } ); - reset(); +}); +test( "programmatic event triggers", function() { + expect(6); + // Test value method - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .slider({ change: function(event, ui) { ok( true, "change triggered by value method" ); @@ -94,8 +106,4 @@ test( "change", function() { }); -test( "stop", function() { - ok( false, "missing test - untested code is broken code." ); -}); - }( jQuery ) ); |