aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/slider/slider_events.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-04-07 10:55:52 -0400
committerScott González <scott.gonzalez@gmail.com>2015-04-09 09:27:00 -0400
commitbde431bb449b1d957d4e0b736111ff342f2a919d (patch)
tree27fd40037c30dbff8ef3b6113e90817ab96b53bf /tests/unit/slider/slider_events.js
parentdc4b015a8b9acdb5bff2d5dd89737b3d8b64097f (diff)
downloadjquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.tar.gz
jquery-ui-bde431bb449b1d957d4e0b736111ff342f2a919d.zip
Tests: Rename files
Ref gh-1528
Diffstat (limited to 'tests/unit/slider/slider_events.js')
-rw-r--r--tests/unit/slider/slider_events.js208
1 files changed, 0 insertions, 208 deletions
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js
deleted file mode 100644
index 0d22577f1..000000000
--- a/tests/unit/slider/slider_events.js
+++ /dev/null
@@ -1,208 +0,0 @@
-define( [
- "jquery",
- "ui/slider"
-], function( $ ) {
-
-module( "slider: events" );
-
-//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( "mouse based interaction", function() {
- expect( 4 );
-
- var element = $( "#slider1" )
- .slider({
- start: function( event ) {
- equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
- },
- slide: function( event) {
- equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
- },
- stop: function( event ) {
- equal( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
- },
- change: function( event ) {
- equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
- }
- });
-
- element.find( ".ui-slider-handle" ).eq( 0 )
- .simulate( "drag", { dx: 10, dy: 10 } );
-
-});
-test( "keyboard based interaction", function() {
- expect( 3 );
-
- // Test keyup at end of handle slide (keyboard)
- var element = $( "#slider1" )
- .slider({
- start: function( event ) {
- equal( event.originalEvent.type, "keydown", "start triggered by keydown" );
- },
- slide: function() {
- ok( false, "Slider never triggered by keys" );
- },
- stop: function( event ) {
- equal( event.originalEvent.type, "keyup", "stop triggered by keyup" );
- },
- change: function( event ) {
- equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
- }
- });
-
- element.find( ".ui-slider-handle" ).eq( 0 )
- .simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } )
- .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
- .simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
-
-});
-test( "programmatic event triggers", function() {
- expect( 6 );
-
- // Test value method
- var element = $( "<div></div>" )
- .slider({
- change: function() {
- ok( true, "change triggered by value method" );
- }
- })
- .slider( "value", 0 );
-
- // Test values method
- element = $( "<div></div>" )
- .slider({
- values: [ 10, 20 ],
- change: function() {
- ok( true, "change triggered by values method" );
- }
- })
- .slider( "values", [ 80, 90 ] );
-
- // Test value option
- element = $( "<div></div>" )
- .slider({
- change: function() {
- ok( true, "change triggered by value option" );
- }
- })
- .slider( "option", "value", 0 );
-
- // Test values option
- element = $( "<div></div>" )
- .slider({
- values: [ 10, 20 ],
- change: function() {
- ok( true, "change triggered by values option" );
- }
- })
- .slider( "option", "values", [ 80, 90 ] );
-
-});
-
-test( "mouse based interaction part two: when handles overlap", function() {
- expect( 6 );
-
- var element = $( "#slider1" )
- .slider({
- values: [ 0, 0, 0 ],
- start: function( event, ui ) {
- equal( handles.index( ui.handle ), 2, "rightmost handle activated when overlapping at minimum (#3736)" );
- }
- }),
- handles = element.find( ".ui-slider-handle" );
- handles.eq( 0 ).simulate( "drag", { dx: 10 } );
- element.slider( "destroy" );
-
- element = $( "#slider1" )
- .slider({
- values: [ 10, 10, 10 ],
- max: 10,
- start: function( event, ui ) {
- equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" );
- }
- }),
- handles = element.find( ".ui-slider-handle" );
- handles.eq( 0 ).simulate( "drag", { dx: -10 } );
- element.slider( "destroy" );
-
- element = $( "#slider1" )
- .slider({
- values: [ 19, 20 ]
- }),
- handles = element.find( ".ui-slider-handle" );
- handles.eq( 0 ).simulate( "drag", { dx: 10 } );
- element.one( "slidestart", function( event, ui ) {
- equal( handles.index( ui.handle ), 0, "left handle activated if left was moved last" );
- });
- handles.eq( 0 ).simulate( "drag", { dx: 10 } );
- element.slider( "destroy" );
-
- element = $( "#slider1" )
- .slider({
- values: [ 19, 20 ]
- }),
- handles = element.find( ".ui-slider-handle" );
- handles.eq( 1 ).simulate( "drag", { dx: -10 } );
- element.one( "slidestart", function( event, ui ) {
- equal( handles.index( ui.handle ), 1, "right handle activated if right was moved last (#3467)" );
- });
- handles.eq( 0 ).simulate( "drag", { dx: 10 } );
-
- element = $( "#slider1" )
- .slider({
- range: true,
- min: 0,
- max: 100,
- values: [ 0, 50 ]
- }),
- handles = element.find( ".ui-slider-handle" );
-
- element.slider( "option", { values: [ 100, 100 ] } );
- handles.eq( 0 ).simulate( "drag", { dx: -10 } );
- equal( element.slider( "values" )[ 0 ], 99, "setting both values of range slider to the maximum doesn't lock slider" );
-
- element.slider( "option", { values: [ 0, 0 ] } );
- handles.eq( 1 ).simulate( "drag", { dx: 10 } );
- equal( element.slider( "values" )[ 1 ], 1, "setting both values of range slider to the minimum doesn't lock slider" );
-});
-
-test( "event data", function() {
- expect( 4 );
-
- var slideHandleIndex = 3,
- values = [ 8, 9, 7, 4 ],
- newValues = [ 8, 9, 7, 5 ],
- element = $( "#slider1" )
- .slider({
- values: values,
- start: function( event, ui ) {
- deepEqual( ui, expectedUiHash, "passing ui to start event" );
- },
- slide: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to slide event" );
- },
- stop: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to stop event" );
- },
- change: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to change event" );
- }
- }),
- handles = element.find( ".ui-slider-handle" ),
- expectedUiHash = {
- handle: handles.eq( slideHandleIndex )[ 0 ],
- handleIndex: slideHandleIndex,
- values: values,
- value: values[ slideHandleIndex ]
- },
- expectedChangedUiHash = $.extend( {}, expectedUiHash, {
- values: newValues,
- value: newValues[ slideHandleIndex ]
- });
-
- handles.eq( slideHandleIndex ).simulate( "drag", { dx: 10 } );
-});
-
-} );