diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-24 08:58:09 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-09-11 08:29:08 -0400 |
commit | e583a512d7cc66a2b3d0915db1b0164b9a0a710e (patch) | |
tree | d82792cc3b9e739114eed02f1552a3252748f59f /tests/unit/slider | |
parent | 62c8217185bdf6b043d76d0e2498c22a043aab2c (diff) | |
download | jquery-ui-e583a512d7cc66a2b3d0915db1b0164b9a0a710e.tar.gz jquery-ui-e583a512d7cc66a2b3d0915db1b0164b9a0a710e.zip |
Slider: Style updates
Ref #14246
Diffstat (limited to 'tests/unit/slider')
-rw-r--r-- | tests/unit/slider/common.js | 2 | ||||
-rw-r--r-- | tests/unit/slider/core.js | 82 | ||||
-rw-r--r-- | tests/unit/slider/events.js | 78 | ||||
-rw-r--r-- | tests/unit/slider/methods.js | 46 | ||||
-rw-r--r-- | tests/unit/slider/options.js | 100 |
5 files changed, 155 insertions, 153 deletions
diff --git a/tests/unit/slider/common.js b/tests/unit/slider/common.js index 5cc3e66c5..df53cda4f 100644 --- a/tests/unit/slider/common.js +++ b/tests/unit/slider/common.js @@ -30,6 +30,6 @@ common.testWidget( "slider", { start: null, stop: null } -}); +} ); } ); diff --git a/tests/unit/slider/core.js b/tests/unit/slider/core.js index 7fdb8c68c..109c9e01a 100644 --- a/tests/unit/slider/core.js +++ b/tests/unit/slider/core.js @@ -14,7 +14,7 @@ module( "slider: core" ); test( "markup structure", function( assert ) { expect( 4 ); - var element = $( "<div>" ).slider({ range: true }), + var element = $( "<div>" ).slider( { range: true } ), handle = element.find( "span" ), range = element.find( "div" ); @@ -22,7 +22,7 @@ test( "markup structure", function( assert ) { assert.hasClasses( range, "ui-slider-range ui-widget-header" ); assert.hasClasses( handle[ 0 ], "ui-slider-handle" ); assert.hasClasses( handle[ 1 ], "ui-slider-handle" ); -}); +} ); test( "keydown HOME on handle sets value to min", function() { expect( 2 ); @@ -38,7 +38,7 @@ test( "keydown HOME on handle sets value to min", function() { element.slider( "value", 0 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); element.slider( "destroy" ); @@ -54,10 +54,10 @@ test( "keydown HOME on handle sets value to min", function() { element.slider( "value", 0 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); - equal(element.slider( "value" ), options.min) ; + equal( element.slider( "value" ), options.min ) ; element.slider( "destroy" ); -}); +} ); test( "keydown END on handle sets value to max", function() { expect( 2 ); @@ -73,7 +73,7 @@ test( "keydown END on handle sets value to max", function() { element.slider( "value", 0 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } ); - equal(element.slider( "value" ), options.max) ; + equal( element.slider( "value" ), options.max ) ; element.slider( "destroy" ); @@ -89,10 +89,10 @@ test( "keydown END on handle sets value to max", function() { element.slider( "value", 0 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.END } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); element.slider( "destroy" ); -}); +} ); test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { expect( 4 ); @@ -106,17 +106,17 @@ test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than }; element.slider( options ); - element.slider( "value", 70); + element.slider( "value", 70 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal(element.slider( "value" ), 90); + equal( element.slider( "value" ), 90 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); - equal(element.slider( "value" ), 100); + equal( element.slider( "value" ), 100 ); element.slider( "destroy" ); - }); -}); + } ); +} ); test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { expect( 4 ); @@ -130,17 +130,17 @@ test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than m }; element.slider( options ); - element.slider( "value", 30); + element.slider( "value", 30 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal(element.slider( "value" ), 10); + equal( element.slider( "value" ), 10 ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); - equal(element.slider( "value" ), 0 ); + equal( element.slider( "value" ), 0 ); element.slider( "destroy" ); - }); -}); + } ); +} ); test( "keydown UP on handle increases value by step, not greater than max", function() { expect( 4 ); @@ -151,15 +151,15 @@ test( "keydown UP on handle increases value by step, not greater than max", func orientation: "horizontal", step: 1 }; - element.slider(options); + element.slider( options ); element.slider( "value", options.max - options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); element.slider( "destroy" ); @@ -175,13 +175,13 @@ test( "keydown UP on handle increases value by step, not greater than max", func element.slider( "value", options.max - options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); element.slider( "destroy" ); -}); +} ); test( "keydown RIGHT on handle increases value by step, not greater than max", function() { expect( 4 ); @@ -192,15 +192,15 @@ test( "keydown RIGHT on handle increases value by step, not greater than max", f orientation: "horizontal", step: 1 }; - element.slider(options); + element.slider( options ); element.slider( "value", options.max - options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal(element.slider( "value" ), options.max); + equal( element.slider( "value" ), options.max ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); element.slider( "destroy" ); @@ -216,13 +216,13 @@ test( "keydown RIGHT on handle increases value by step, not greater than max", f element.slider( "value", options.max - options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); - equal(element.slider( "value" ), options.max ); + equal( element.slider( "value" ), options.max ); element.slider( "destroy" ); -}); +} ); test( "keydown DOWN on handle decreases value by step, not less than min", function() { expect( 4 ); @@ -238,10 +238,10 @@ test( "keydown DOWN on handle decreases value by step, not less than min", funct element.slider( "value", options.min + options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal(element.slider( "value" ), options.min); + equal( element.slider( "value" ), options.min ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); element.slider( "destroy" ); @@ -257,13 +257,13 @@ test( "keydown DOWN on handle decreases value by step, not less than min", funct element.slider( "value", options.min + options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal(element.slider( "value" ), options.min); + equal( element.slider( "value" ), options.min ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); element.slider( "destroy" ); -}); +} ); test( "keydown LEFT on handle decreases value by step, not less than min", function() { expect( 4 ); @@ -274,15 +274,15 @@ test( "keydown LEFT on handle decreases value by step, not less than min", funct orientation: "horizontal", step: 1 }; - element.slider(options); + element.slider( options ); element.slider( "value", options.min + options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); element.slider( "destroy" ); @@ -298,12 +298,12 @@ test( "keydown LEFT on handle decreases value by step, not less than min", funct element.slider( "value", options.min + options.step ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); - equal(element.slider( "value" ), options.min ); + equal( element.slider( "value" ), options.min ); element.slider( "destroy" ); -}); +} ); } ); diff --git a/tests/unit/slider/events.js b/tests/unit/slider/events.js index 0256a2093..2cf67b5fe 100644 --- a/tests/unit/slider/events.js +++ b/tests/unit/slider/events.js @@ -13,11 +13,11 @@ test( "mouse based interaction", function() { expect( 4 ); var element = $( "#slider1" ) - .slider({ + .slider( { start: function( event ) { equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); }, - slide: function( event) { + slide: function( event ) { equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" ); }, stop: function( event ) { @@ -26,18 +26,18 @@ test( "mouse based interaction", function() { 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({ + .slider( { start: function( event ) { equal( event.originalEvent.type, "keydown", "start triggered by keydown" ); }, @@ -50,113 +50,113 @@ test( "keyboard based interaction", function() { 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({ + .slider( { change: function() { ok( true, "change triggered by value method" ); } - }) + } ) .slider( "value", 0 ); // Test values method element = $( "<div></div>" ) - .slider({ + .slider( { values: [ 10, 20 ], change: function() { ok( true, "change triggered by values method" ); } - }) + } ) .slider( "values", [ 80, 90 ] ); // Test value option element = $( "<div></div>" ) - .slider({ + .slider( { change: function() { ok( true, "change triggered by value option" ); } - }) + } ) .slider( "option", "value", 0 ); // Test values option element = $( "<div></div>" ) - .slider({ + .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({ + .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({ + .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({ + .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({ + .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({ + .slider( { range: true, min: 0, max: 100, values: [ 0, 50 ] - }), + } ), handles = element.find( ".ui-slider-handle" ); element.slider( "option", { values: [ 100, 100 ] } ); @@ -166,7 +166,7 @@ test( "mouse based interaction part two: when handles overlap", function() { 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( 6 ); @@ -175,7 +175,7 @@ test( "event data", function() { values = [ 8, 9, 7, 4 ], newValues = [ 8, 9, 7, 5 ], element = $( "#slider1" ) - .slider({ + .slider( { values: values, start: function( event, ui ) { deepEqual( ui, expectedUiHash, "passing ui to start event" ); @@ -189,7 +189,7 @@ test( "event data", function() { change: function( event, ui ) { deepEqual( ui, expectedChangedUiHash, "passing ui to change event" ); } - }), + } ), handles = element.find( ".ui-slider-handle" ), expectedUiHash = { handle: handles.eq( slideHandleIndex )[ 0 ], @@ -200,33 +200,33 @@ test( "event data", function() { expectedChangedUiHash = $.extend( {}, expectedUiHash, { values: newValues, value: newValues[ slideHandleIndex ] - }); + } ); handles.eq( slideHandleIndex ).simulate( "drag", { dx: 10 } ); element.slider( "destroy" ); - element = $( "#slider1" ).slider({ + element = $( "#slider1" ).slider( { min: 0, max: 100, value: 1, - slide: function ( event, ui ) { + slide: function( event, ui ) { equal( ui.value, 0, "should pass 0 value if slider reaches it" ); } - }); + } ); handles = element.find( ".ui-slider-handle" ); handles.eq( 0 ).simulate( "drag", { dx: -10 } ); element.slider( "destroy" ); - element = $( "#slider1" ).slider({ + element = $( "#slider1" ).slider( { min: 0, max: 100, values: [ 1, 2 ], - slide: function ( event, ui ) { + slide: function( event, ui ) { equal( ui.value, 0, "should pass 0 value if one of handles reaches it" ); } - }); + } ); handles = element.find( ".ui-slider-handle" ); handles.eq( 0 ).simulate( "drag", { dx: -10 } ); -}); +} ); } ); diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js index a4187bd7f..15b2e8726 100644 --- a/tests/unit/slider/methods.js +++ b/tests/unit/slider/methods.js @@ -6,7 +6,7 @@ define( [ module( "slider: methods" ); test( "init", function() { - expect(5); + expect( 5 ); $( "<div></div>" ).appendTo( "body" ).slider().remove(); ok( true, ".slider() called on element" ); @@ -24,65 +24,67 @@ test( "init", function() { $( "<div></div>" ).slider().slider( "option", "foo", "bar" ).remove(); ok( true, "arbitrary option setter after init" ); -}); +} ); test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#slider1", function() { $( "#slider1" ).slider().slider( "destroy" ); - }); -}); + } ); +} ); test( "enable", function( assert ) { expect( 3 ); var element, expected = $( "<div></div>" ).slider(), actual = expected.slider( "enable" ); - equal(actual, expected, "enable is chainable" ); + equal( actual, expected, "enable is chainable" ); - element = $( "<div></div>" ).slider({ disabled: true }); + element = $( "<div></div>" ).slider( { disabled: true } ); assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" ); element.slider( "enable" ); assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" ); -}); +} ); test( "disable", function( assert ) { expect( 4 ); var element, expected = $( "<div></div>" ).slider(), actual = expected.slider( "disable" ); - equal(actual, expected, "disable is chainable" ); + equal( actual, expected, "disable is chainable" ); - element = $( "<div></div>" ).slider({ disabled: false }); + element = $( "<div></div>" ).slider( { disabled: false } ); assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" ); element.slider( "disable" ); assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" ); ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" ); -}); +} ); test( "value", function() { expect( 19 ); - $( [ false, "min", "max" ] ).each(function() { - var element = $( "<div></div>" ).slider({ + $( [ false, "min", "max" ] ).each( function() { + var element = $( "<div></div>" ).slider( { range: this, value: 5 - }); + } ); equal( element.slider( "value" ), 5, "range: " + this + " slider method get" ); - equal( element.slider( "value", 10), element, "value method is chainable" ); + equal( element.slider( "value", 10 ), element, "value method is chainable" ); equal( element.slider( "value" ), 10, "range: " + this + " slider method set" ); element.remove(); - }); - var element = $( "<div></div>" ).slider({ + } ); + var element = $( "<div></div>" ).slider( { min: -1, value: 0, max: 1 - }); + } ); + // min with value option vs value method element.slider( "option", "value", -2 ); equal( element.slider( "option", "value" ), -2, "value option does not respect min" ); equal( element.slider( "value" ), -1, "value method get respects min" ); equal( element.slider( "value", -2 ), element, "value method is chainable" ); equal( element.slider( "option", "value" ), -1, "value method set respects min" ); + // max with value option vs value method - element.slider( "option", "value", 2); + element.slider( "option", "value", 2 ); equal( element.slider( "option", "value" ), 2, "value option does not respect max" ); equal( element.slider( "value" ), 1, "value method get respects max" ); equal( element.slider( "value", 2 ), element, "value method is chainable" ); @@ -94,20 +96,20 @@ test( "value", function() { value: 2, max: 2.4, step: 0.01 - }); + } ); element.slider( "option", "value", 2.4 ); equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" ); - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { value: 100, min: 10, max: 500, step: 50 - }); + } ); element.slider( "option", "value", 510 ); equal( element.slider( "value" ), 460, "value is restricted to maximum valid step" ); -}); +} ); //test( "values", function() { // ok(false, "missing test - untested code is broken code." ); diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js index f6b61a2b3..031031cdc 100644 --- a/tests/unit/slider/options.js +++ b/tests/unit/slider/options.js @@ -11,18 +11,18 @@ function handle() { module( "slider: options" ); -test( "disabled", function( assert ){ +test( "disabled", function( assert ) { expect( 8 ); var count = 0; element = $( "#slider1" ).slider(); element.on( "slidestart", function() { count++; - }); + } ); // Enabled assert.lacksClasses( element, "ui-slider-disabled" ); - equal( element.slider( "option", "disabled" ), false , "is not disabled" ); + equal( element.slider( "option", "disabled" ), false, "is not disabled" ); handle().simulate( "drag", { dx: 10 } ); equal( count, 1, "slider moved" ); @@ -40,7 +40,7 @@ test( "disabled", function( assert ){ handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); equal( count, 2, "slider did not move" ); -}); +} ); test( "max", function() { expect( 5 ); @@ -87,7 +87,7 @@ test( "max", function() { ok( element.slider( "value" ) === options.max, "value method will max, step is changed and step is float" ); element.slider( "destroy" ); -}); +} ); test( "min", function() { expect( 2 ); @@ -106,7 +106,7 @@ test( "min", function() { ok( element.slider( "value" ) === options.min, "value method is contained by min" ); element.slider( "destroy" ); -}); +} ); test( "orientation", function( assert ) { expect( 14 ); @@ -126,7 +126,7 @@ test( "orientation", function( assert ) { assert.hasClasses( element, "ui-slider-horizontal" ); assert.lacksClasses( element, "ui-slider-vertical" ); equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" ); - equal( handle()[0].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" ); + equal( handle()[ 0 ].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" ); element.slider( "destroy" ) ; @@ -143,17 +143,17 @@ test( "orientation", function( assert ) { assert.hasClasses( element, "ui-slider-vertical" ); assert.lacksClasses( element, "ui-slider-horizontal" ); equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" ); - equal( handle()[0].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" ); + equal( handle()[ 0 ].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" ); element.slider( "destroy" ); newValue = 7; - rangeSize = 500 - (500 * newValue / 10); - element = $( "#slider2" ).slider({ + rangeSize = 500 - ( 500 * newValue / 10 ); + element = $( "#slider2" ).slider( { range: "max", min: 0, max: 10 - }); + } ); element.slider( "option", "value", newValue ); element.slider( "option", "orientation", "vertical" ); @@ -170,11 +170,11 @@ test( "orientation", function( assert ) { element.slider( "destroy" ); - element = $( "#slider2" ).slider({ + element = $( "#slider2" ).slider( { range: true, min: 0, max: 100 - }); + } ); element.slider( "option", { values: [ 60, 70 ] } ); notEqual( element.find( ".ui-slider-range " ).position().left, 0, "range should not pull over to the track's border" ); @@ -183,19 +183,19 @@ test( "orientation", function( assert ) { "range should pull over to the track's border" ); element.slider( "destroy" ); -}); +} ); //spec: http://wiki.jqueryui.com/Slider#specs // value option/method: the value option is not restricted by min/max/step. // What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) test( "step", function() { expect( 9 ); - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { min: 0, value: 0, step: 10, max: 100 - }); + } ); equal( element.slider( "value" ), 0 ); element.slider( "value", 1 ); @@ -210,12 +210,12 @@ test( "step", function() { element.slider( "value", 19 ); equal( element.slider( "value" ), 20 ); - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { min: 0, value: 0, step: 20, max: 100 - }); + } ); element.slider( "value", 0 ); element.slider( "option", "value", 1 ); @@ -231,7 +231,7 @@ test( "step", function() { equal( element.slider( "value" ), 20 ); element.slider( "destroy" ); -}); +} ); //test( "value", function() { // ok(false, "missing test - untested code is broken code." ); @@ -243,13 +243,13 @@ test( "values", function() { // Testing multiple ranges on the same page, the object reference to the values // property is preserved via multiple range elements, so updating options.values // of 1 slider updates options.values of all the others - var ranges = $([ + var ranges = $( [ document.createElement( "div" ), document.createElement( "div" ) - ]).slider({ + ] ).slider( { range: true, values: [ 25, 75 ] - }); + } ); notStrictEqual( ranges.eq( 0 ).slider( "instance" ).options.values, @@ -264,43 +264,43 @@ test( "values", function() { ranges.eq( 1 ).slider( "values", 0 ), "the values for multiple sliders should be different" ); -}); +} ); test( "range", function( assert ) { expect( 32 ); var range; // Min - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: "min", min: 1, max: 10, step: 1 - }); + } ); equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle" ); equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" ); element.slider( "destroy" ); // Max - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: "max", min: 1, max: 10, step: 1 - }); + } ); equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle" ); equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" ); element.slider( "destroy" ); // True - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: true, min: 1, max: 10, step: 1 - }); + } ); range = element.find( ".ui-slider-range" ); equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" ); @@ -308,12 +308,12 @@ test( "range", function( assert ) { element.slider( "destroy" ); // Change range from min to max - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: "min", min: 1, max: 10, step: 1 - }).slider( "option", "range", "max" ); + } ).slider( "option", "range", "max" ); equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle" ); equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" ); @@ -321,12 +321,12 @@ test( "range", function( assert ) { element.slider( "destroy" ); // Change range from max to min - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: "max", min: 1, max: 10, step: 1 - }).slider( "option", "range", "min" ); + } ).slider( "option", "range", "min" ); equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle" ); equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" ); @@ -334,53 +334,53 @@ test( "range", function( assert ) { element.slider( "destroy" ); // Change range from max to true - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: "max", min: 1, max: 10, step: 1 - }).slider( "option", "range", true ); + } ).slider( "option", "range", true ); equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles" ); equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" ); equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" ); - equal( element.slider( "option", "value" ), 0 , "option value" ); - equal( element.slider( "value" ), 1 , "value" ); - deepEqual( element.slider( "option", "values" ), [1, 1], "option values" ); - deepEqual( element.slider( "values" ), [1, 1], "values" ); + equal( element.slider( "option", "value" ), 0, "option value" ); + equal( element.slider( "value" ), 1, "value" ); + deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" ); + deepEqual( element.slider( "values" ), [ 1, 1 ], "values" ); element.slider( "destroy" ); // Change range from true to min - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: true, min: 1, max: 10, step: 1 - }).slider( "option", "range", "min" ); + } ).slider( "option", "range", "min" ); equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle" ); equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" ); equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" ); equal( element.slider( "option", "value" ), 1, "value" ); - equal( element.slider( "value" ), 1 , "value" ); + equal( element.slider( "value" ), 1, "value" ); equal( element.slider( "option", "values" ), null, "values" ); - deepEqual( element.slider( "values" ), [] , "values" ); + deepEqual( element.slider( "values" ), [], "values" ); element.slider( "destroy" ); // Change range from true to false - element = $( "<div></div>" ).slider({ + element = $( "<div></div>" ).slider( { range: true, min: 1, max: 10, step: 1 - }).slider( "option", "range", false ); + } ).slider( "option", "range", false ); equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from true to false, both handles remain" ); equal( element.find( ".ui-slider-range" ).length, 0, "range switch from true to false" ); - equal( element.slider( "option", "value" ), 0 , "option value" ); - equal( element.slider( "value" ), 1 , "value" ); - deepEqual( element.slider( "option", "values" ), [1, 1], "option values" ); - deepEqual( element.slider( "values" ), [1, 1], "values" ); + equal( element.slider( "option", "value" ), 0, "option value" ); + equal( element.slider( "value" ), 1, "value" ); + deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" ); + deepEqual( element.slider( "values" ), [ 1, 1 ], "values" ); element.slider( "destroy" ); -}); +} ); } ); |