aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/slider
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2010-03-17 15:31:17 +0000
committerRichard Worth <rdworth@gmail.com>2010-03-17 15:31:17 +0000
commit8b885b3d527a64db4317ef1d00e0cc87e2fe0582 (patch)
tree1dbdef78a67cc3c75d6ecba1696283ba07c7db02 /tests/unit/slider
parent5c5f9ad69542e7ae3806611da648c463e96c32ba (diff)
downloadjquery-ui-8b885b3d527a64db4317ef1d00e0cc87e2fe0582.tar.gz
jquery-ui-8b885b3d527a64db4317ef1d00e0cc87e2fe0582.zip
Slider unit tests: slider event change
Diffstat (limited to 'tests/unit/slider')
-rw-r--r--tests/unit/slider/slider_events.js57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js
index 22e908bdd..a3d6c5282 100644
--- a/tests/unit/slider/slider_events.js
+++ b/tests/unit/slider/slider_events.js
@@ -2,6 +2,8 @@
* slider_events.js
*/
(function($) {
+
+var el;
module( "slider: events" );
@@ -13,8 +15,61 @@ 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() {
- ok( false, "missing test - untested code is broken code." );
+ expect(4);
+
+ var handle;
+ // Test mouseup at end of handle slide (mouse)
+ el = $( "<div></div>" )
+ .appendTo( "body" )
+ .slider({
+ change: function(event, ui) {
+ ok( true, "change triggered by mouseup at end of handle slide (mouse)" );
+ }
+ });
+
+ el.find( ".ui-slider-handle" ).eq( 0 )
+ .simulate( "drag", { dx: 10, dy: 10 } );
+
+ reset();
+ // Test keyup at end of handle slide (keyboard)
+ el = $( "<div></div>" )
+ .appendTo( "body" )
+ .slider({
+ change: function(event, ui) {
+ ok( true, "change triggered by keyup at end of handle slide (keyboard)" );
+ }
+ });
+
+ el.find( ".ui-slider-handle" ).eq( 0 )
+ .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } )
+ .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
+ .simulate( "keyup", { charCode: $.ui.keyCode.LEFT } );
+
+ reset();
+ // Test value method
+ el = $( "<div></div>" )
+ .slider({
+ change: function(event, ui) {
+ ok( true, "change triggered by value method" );
+ }
+ })
+ .slider( "value", 0 );
+
+ reset();
+ // Test value option
+ el = $( "<div></div>" )
+ .slider({
+ change: function(event, ui) {
+ ok( true, "change triggered by value option" );
+ }
+ })
+ .slider( "option", "value", 0 );
+
});
test( "stop", function() {