aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAmanpreet Singh <apsdehal@gmail.com>2016-04-06 18:48:13 +0530
committerAmanpreet Singh <apsdehal@gmail.com>2016-04-14 00:14:57 +0530
commit38d473708b6af4166ca01c938325f8910e66cf22 (patch)
treed866ccc854321f9a8c5e55617613faa4d1907177 /tests
parentd00c5641b921b39d5bd5fd79183bed720de6ac18 (diff)
downloadjquery-ui-38d473708b6af4166ca01c938325f8910e66cf22.tar.gz
jquery-ui-38d473708b6af4166ca01c938325f8910e66cf22.zip
Slider: Shift to use no globals
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/slider/core.js89
-rw-r--r--tests/unit/slider/events.js73
-rw-r--r--tests/unit/slider/methods.js99
-rw-r--r--tests/unit/slider/options.js169
4 files changed, 217 insertions, 213 deletions
diff --git a/tests/unit/slider/core.js b/tests/unit/slider/core.js
index 109c9e01a..57affb0d1 100644
--- a/tests/unit/slider/core.js
+++ b/tests/unit/slider/core.js
@@ -1,7 +1,8 @@
define( [
+ "qunit",
"jquery",
"ui/widgets/slider"
-], function( $ ) {
+], function( QUnit, $ ) {
var element, options;
@@ -10,10 +11,10 @@ function handle() {
}
// Slider Tests
-module( "slider: core" );
+QUnit.module( "slider: core" );
-test( "markup structure", function( assert ) {
- expect( 4 );
+QUnit.test( "markup structure", function( assert ) {
+ assert.expect( 4 );
var element = $( "<div>" ).slider( { range: true } ),
handle = element.find( "span" ),
range = element.find( "div" );
@@ -24,8 +25,8 @@ test( "markup structure", function( assert ) {
assert.hasClasses( handle[ 1 ], "ui-slider-handle" );
} );
-test( "keydown HOME on handle sets value to min", function() {
- expect( 2 );
+QUnit.test( "keydown HOME on handle sets value to min", function( assert ) {
+ assert.expect( 2 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -38,7 +39,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 );
+ assert.equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -54,13 +55,13 @@ 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 ) ;
+ assert.equal( element.slider( "value" ), options.min ) ;
element.slider( "destroy" );
} );
-test( "keydown END on handle sets value to max", function() {
- expect( 2 );
+QUnit.test( "keydown END on handle sets value to max", function( assert ) {
+ assert.expect( 2 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -73,7 +74,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 ) ;
+ assert.equal( element.slider( "value" ), options.max ) ;
element.slider( "destroy" );
@@ -89,13 +90,13 @@ 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 );
+ assert.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 );
+QUnit.test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function( assert ) {
+ assert.expect( 4 );
$.each( [ "horizontal", "vertical" ], function( i, orientation ) {
element = $( "<div></div>" );
options = {
@@ -109,17 +110,17 @@ test( "keydown PAGE_UP on handle increases value by 1/5 range, not greater than
element.slider( "value", 70 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal( element.slider( "value" ), 90 );
+ assert.equal( element.slider( "value" ), 90 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equal( element.slider( "value" ), 100 );
+ assert.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 );
+QUnit.test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function( assert ) {
+ assert.expect( 4 );
$.each( [ "horizontal", "vertical" ], function( i, orientation ) {
element = $( "<div></div>" );
options = {
@@ -133,17 +134,17 @@ test( "keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than m
element.slider( "value", 30 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( element.slider( "value" ), 10 );
+ assert.equal( element.slider( "value" ), 10 );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equal( element.slider( "value" ), 0 );
+ assert.equal( element.slider( "value" ), 0 );
element.slider( "destroy" );
} );
} );
-test( "keydown UP on handle increases value by step, not greater than max", function() {
- expect( 4 );
+QUnit.test( "keydown UP on handle increases value by step, not greater than max", function( assert ) {
+ assert.expect( 4 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -156,10 +157,10 @@ 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 );
+ assert.equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal( element.slider( "value" ), options.max );
+ assert.equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
@@ -175,16 +176,16 @@ 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 );
+ assert.equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equal( element.slider( "value" ), options.max );
+ assert.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 );
+QUnit.test( "keydown RIGHT on handle increases value by step, not greater than max", function( assert ) {
+ assert.expect( 4 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -197,10 +198,10 @@ 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 );
+ assert.equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal( element.slider( "value" ), options.max );
+ assert.equal( element.slider( "value" ), options.max );
element.slider( "destroy" );
@@ -216,16 +217,16 @@ 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 );
+ assert.equal( element.slider( "value" ), options.max );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal( element.slider( "value" ), options.max );
+ assert.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 );
+QUnit.test( "keydown DOWN on handle decreases value by step, not less than min", function( assert ) {
+ assert.expect( 4 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -238,10 +239,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 );
+ assert.equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal( element.slider( "value" ), options.min );
+ assert.equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -257,16 +258,16 @@ 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 );
+ assert.equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equal( element.slider( "value" ), options.min );
+ assert.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 );
+QUnit.test( "keydown LEFT on handle decreases value by step, not less than min", function( assert ) {
+ assert.expect( 4 );
element = $( "<div></div>" );
options = {
max: 5,
@@ -279,10 +280,10 @@ 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 );
+ assert.equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal( element.slider( "value" ), options.min );
+ assert.equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
@@ -298,10 +299,10 @@ 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 );
+ assert.equal( element.slider( "value" ), options.min );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equal( element.slider( "value" ), options.min );
+ assert.equal( element.slider( "value" ), options.min );
element.slider( "destroy" );
} );
diff --git a/tests/unit/slider/events.js b/tests/unit/slider/events.js
index 2cf67b5fe..d0459db64 100644
--- a/tests/unit/slider/events.js
+++ b/tests/unit/slider/events.js
@@ -1,30 +1,31 @@
define( [
+ "qunit",
"jquery",
"ui/widgets/slider"
-], function( $ ) {
+], function( QUnit, $ ) {
-module( "slider: events" );
+QUnit.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 );
+QUnit.test( "mouse based interaction", function( assert ) {
+ assert.expect( 4 );
var element = $( "#slider1" )
.slider( {
start: function( event ) {
- equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
+ assert.equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
},
slide: function( event ) {
- equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
+ assert.equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
},
stop: function( event ) {
- equal( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
+ assert.equal( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
},
change: function( event ) {
- equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
+ assert.equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
}
} );
@@ -32,23 +33,23 @@ test( "mouse based interaction", function() {
.simulate( "drag", { dx: 10, dy: 10 } );
} );
-test( "keyboard based interaction", function() {
- expect( 3 );
+QUnit.test( "keyboard based interaction", function( assert ) {
+ assert.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" );
+ assert.equal( event.originalEvent.type, "keydown", "start triggered by keydown" );
},
slide: function() {
- ok( false, "Slider never triggered by keys" );
+ assert.ok( false, "Slider never triggered by keys" );
},
stop: function( event ) {
- equal( event.originalEvent.type, "keyup", "stop triggered by keyup" );
+ assert.equal( event.originalEvent.type, "keyup", "stop triggered by keyup" );
},
change: function( event ) {
- equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
+ assert.equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
}
} );
@@ -58,14 +59,14 @@ test( "keyboard based interaction", function() {
.simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
} );
-test( "programmatic event triggers", function() {
- expect( 6 );
+QUnit.test( "programmatic event triggers", function( assert ) {
+ assert.expect( 6 );
// Test value method
var element = $( "<div></div>" )
.slider( {
change: function() {
- ok( true, "change triggered by value method" );
+ assert.ok( true, "change triggered by value method" );
}
} )
.slider( "value", 0 );
@@ -75,7 +76,7 @@ test( "programmatic event triggers", function() {
.slider( {
values: [ 10, 20 ],
change: function() {
- ok( true, "change triggered by values method" );
+ assert.ok( true, "change triggered by values method" );
}
} )
.slider( "values", [ 80, 90 ] );
@@ -84,7 +85,7 @@ test( "programmatic event triggers", function() {
element = $( "<div></div>" )
.slider( {
change: function() {
- ok( true, "change triggered by value option" );
+ assert.ok( true, "change triggered by value option" );
}
} )
.slider( "option", "value", 0 );
@@ -94,21 +95,21 @@ test( "programmatic event triggers", function() {
.slider( {
values: [ 10, 20 ],
change: function() {
- ok( true, "change triggered by values option" );
+ assert.ok( true, "change triggered by values option" );
}
} )
.slider( "option", "values", [ 80, 90 ] );
} );
-test( "mouse based interaction part two: when handles overlap", function() {
- expect( 6 );
+QUnit.test( "mouse based interaction part two: when handles overlap", function( assert ) {
+ assert.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)" );
+ assert.equal( handles.index( ui.handle ), 2, "rightmost handle activated when overlapping at minimum (#3736)" );
}
} ),
handles = element.find( ".ui-slider-handle" );
@@ -120,7 +121,7 @@ test( "mouse based interaction part two: when handles overlap", function() {
values: [ 10, 10, 10 ],
max: 10,
start: function( event, ui ) {
- equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" );
+ assert.equal( handles.index( ui.handle ), 0, "leftmost handle activated when overlapping at maximum" );
}
} ),
handles = element.find( ".ui-slider-handle" );
@@ -134,7 +135,7 @@ test( "mouse based interaction part two: when handles overlap", function() {
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" );
+ assert.equal( handles.index( ui.handle ), 0, "left handle activated if left was moved last" );
} );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
element.slider( "destroy" );
@@ -146,7 +147,7 @@ test( "mouse based interaction part two: when handles overlap", function() {
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)" );
+ assert.equal( handles.index( ui.handle ), 1, "right handle activated if right was moved last (#3467)" );
} );
handles.eq( 0 ).simulate( "drag", { dx: 10 } );
@@ -161,15 +162,15 @@ test( "mouse based interaction part two: when handles overlap", function() {
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" );
+ assert.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" );
+ assert.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 );
+QUnit.test( "event data", function( assert ) {
+ assert.expect( 6 );
var slideHandleIndex = 3,
values = [ 8, 9, 7, 4 ],
@@ -178,16 +179,16 @@ test( "event data", function() {
.slider( {
values: values,
start: function( event, ui ) {
- deepEqual( ui, expectedUiHash, "passing ui to start event" );
+ assert.deepEqual( ui, expectedUiHash, "passing ui to start event" );
},
slide: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to slide event" );
+ assert.deepEqual( ui, expectedChangedUiHash, "passing ui to slide event" );
},
stop: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to stop event" );
+ assert.deepEqual( ui, expectedChangedUiHash, "passing ui to stop event" );
},
change: function( event, ui ) {
- deepEqual( ui, expectedChangedUiHash, "passing ui to change event" );
+ assert.deepEqual( ui, expectedChangedUiHash, "passing ui to change event" );
}
} ),
handles = element.find( ".ui-slider-handle" ),
@@ -210,7 +211,7 @@ test( "event data", function() {
max: 100,
value: 1,
slide: function( event, ui ) {
- equal( ui.value, 0, "should pass 0 value if slider reaches it" );
+ assert.equal( ui.value, 0, "should pass 0 value if slider reaches it" );
}
} );
handles = element.find( ".ui-slider-handle" );
@@ -222,7 +223,7 @@ test( "event data", function() {
max: 100,
values: [ 1, 2 ],
slide: function( event, ui ) {
- equal( ui.value, 0, "should pass 0 value if one of handles reaches it" );
+ assert.equal( ui.value, 0, "should pass 0 value if one of handles reaches it" );
}
} );
handles = element.find( ".ui-slider-handle" );
diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js
index 5c0cbb7bd..ea058cef2 100644
--- a/tests/unit/slider/methods.js
+++ b/tests/unit/slider/methods.js
@@ -1,44 +1,45 @@
define( [
+ "qunit",
"jquery",
"ui/widgets/slider"
-], function( $ ) {
+], function( QUnit, $ ) {
-module( "slider: methods" );
+QUnit.module( "slider: methods" );
-test( "init", function() {
- expect( 5 );
+QUnit.test( "init", function( assert ) {
+ assert.expect( 5 );
$( "<div></div>" ).appendTo( "body" ).slider().remove();
- ok( true, ".slider() called on element" );
+ assert.ok( true, ".slider() called on element" );
$( [] ).slider().remove();
- ok( true, ".slider() called on empty collection" );
+ assert.ok( true, ".slider() called on empty collection" );
$( "<div></div>" ).slider().remove();
- ok( true, ".slider() called on disconnected DOMElement" );
+ assert.ok( true, ".slider() called on disconnected DOMElement" );
var element = $( "<div></div>" ).slider();
element.slider( "option", "foo" );
element.remove();
- ok( true, "arbitrary option getter after init" );
+ assert.ok( true, "arbitrary option getter after init" );
$( "<div></div>" ).slider().slider( "option", "foo", "bar" ).remove();
- ok( true, "arbitrary option setter after init" );
+ assert.ok( true, "arbitrary option setter after init" );
} );
-test( "destroy", function( assert ) {
- expect( 1 );
+QUnit.test( "destroy", function( assert ) {
+ assert.expect( 1 );
assert.domEqual( "#slider1", function() {
$( "#slider1" ).slider().slider( "destroy" );
} );
} );
-test( "enable", function( assert ) {
- expect( 3 );
+QUnit.test( "enable", function( assert ) {
+ assert.expect( 3 );
var element,
expected = $( "<div></div>" ).slider(),
actual = expected.slider( "enable" );
- equal( actual, expected, "enable is chainable" );
+ assert.equal( actual, expected, "enable is chainable" );
element = $( "<div></div>" ).slider( { disabled: true } );
assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" );
@@ -46,49 +47,49 @@ test( "enable", function( assert ) {
assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" );
} );
-test( "disable", function( assert ) {
- expect( 4 );
+QUnit.test( "disable", function( assert ) {
+ assert.expect( 4 );
var element,
expected = $( "<div></div>" ).slider(),
actual = expected.slider( "disable" );
- equal( actual, expected, "disable is chainable" );
+ assert.equal( actual, expected, "disable is chainable" );
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" );
+ assert.ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" );
} );
-test( "value", function() {
- expect( 19 );
+QUnit.test( "value", function( assert ) {
+ assert.expect( 19 );
$( [ 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, "range: " + this + " slider method set" );
+ assert.equal( element.slider( "value" ), 5, "range: " + this + " slider method get" );
+ assert.equal( element.slider( "value", 10 ), element, "value method is chainable" );
+ assert.equal( element.slider( "value" ), 10, "range: " + this + " slider method set" );
element.remove();
} );
var element = $( "<div></div>" ).slider( {
min: -1, value: 0, max: 1
} );
- // min with value option vs value method
+ // 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" );
+ assert.equal( element.slider( "option", "value" ), -2, "value option does not respect min" );
+ assert.equal( element.slider( "value" ), -1, "value method get respects min" );
+ assert.equal( element.slider( "value", -2 ), element, "value method is chainable" );
+ assert.equal( element.slider( "option", "value" ), -1, "value method set respects min" );
- // max with value option vs value method
+ // Max with value option vs value method
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" );
- equal( element.slider( "option", "value" ), 1, "value method set respects max" );
+ assert.equal( element.slider( "option", "value" ), 2, "value option does not respect max" );
+ assert.equal( element.slider( "value" ), 1, "value method get respects max" );
+ assert.equal( element.slider( "value", 2 ), element, "value method is chainable" );
+ assert.equal( element.slider( "option", "value" ), 1, "value method set respects max" );
// Set max value with step 0.01
element.slider( "option", {
@@ -98,7 +99,7 @@ test( "value", function() {
step: 0.01
} );
element.slider( "option", "value", 2.4 );
- equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" );
+ assert.equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" );
element = $( "<div></div>" ).slider( {
value: 100,
@@ -108,11 +109,11 @@ test( "value", function() {
} );
element.slider( "option", "value", 510 );
- equal( element.slider( "value" ), 460, "value is restricted to maximum valid step" );
+ assert.equal( element.slider( "value" ), 460, "value is restricted to maximum valid step" );
} );
-test( "values, single step", function() {
- expect( 8 );
+QUnit.test( "values, single step", function( assert ) {
+ assert.expect( 8 );
var element = $( "<div></div>" ).slider( {
range: false,
@@ -122,29 +123,29 @@ test( "values, single step", function() {
values: [ 20 ]
} );
- deepEqual( element.slider( "values" ), [ 20 ], "range: false, values - get value for handle" );
- equal( element.slider( "values", 0 ), 20, "values (index) - get value of handle" );
+ assert.deepEqual( element.slider( "values" ), [ 20 ], "range: false, values - get value for handle" );
+ assert.equal( element.slider( "values", 0 ), 20, "values (index) - get value of handle" );
element.slider( "values", 0, 5 );
- equal( element.slider( "values", 0 ), 10, "values (index) - restrict against min" );
+ assert.equal( element.slider( "values", 0 ), 10, "values (index) - restrict against min" );
element.slider( "values", 0, 110 );
- equal( element.slider( "values", 0 ), 100, "values (index) - restrict against max" );
+ assert.equal( element.slider( "values", 0 ), 100, "values (index) - restrict against max" );
element.slider( "option", "range", true );
element.slider( "values", [ 20, 90 ] );
- deepEqual( element.slider( "values" ), [ 20, 90 ], "range: true, values - get value for all handles" );
- equal( element.slider( "values", 0 ), 20, "values (index) - 1st handle" );
- equal( element.slider( "values", 1 ), 90, "values (index) - 2nd handle" );
+ assert.deepEqual( element.slider( "values" ), [ 20, 90 ], "range: true, values - get value for all handles" );
+ assert.equal( element.slider( "values", 0 ), 20, "values (index) - 1st handle" );
+ assert.equal( element.slider( "values", 1 ), 90, "values (index) - 2nd handle" );
element.slider( "values", [ 5, 110 ] );
- deepEqual( element.slider( "values" ), [ 10, 100 ], "values - restricted against min and max" );
+ assert.deepEqual( element.slider( "values" ), [ 10, 100 ], "values - restricted against min and max" );
element.slider( "destroy" );
} );
-test( "values, multi step", function() {
- expect( 2 );
+QUnit.test( "values, multi step", function( assert ) {
+ assert.expect( 2 );
var element = $( "<div></div>" ).slider( {
range: false,
@@ -153,10 +154,10 @@ test( "values, multi step", function() {
step: 3,
values: [ 9, 12 ]
} );
- deepEqual( element.slider( "values" ), [ 9, 12 ], "values - evenly divisible by step" );
+ assert.deepEqual( element.slider( "values" ), [ 9, 12 ], "values - evenly divisible by step" );
element.slider( "values", [ 10, 20 ] );
- deepEqual( element.slider( "values" ), [ 9, 18 ], "values - not evenly divisible by step" );
+ assert.deepEqual( element.slider( "values" ), [ 9, 18 ], "values - not evenly divisible by step" );
element.slider( "destroy" );
} );
diff --git a/tests/unit/slider/options.js b/tests/unit/slider/options.js
index 5f3ea1111..d1eb2b374 100644
--- a/tests/unit/slider/options.js
+++ b/tests/unit/slider/options.js
@@ -1,7 +1,8 @@
define( [
+ "qunit",
"jquery",
"ui/widgets/slider"
-], function( $ ) {
+], function( QUnit, $ ) {
var element, options;
@@ -9,10 +10,10 @@ function handle() {
return element.find( ".ui-slider-handle" );
}
-module( "slider: options" );
+QUnit.module( "slider: options" );
-test( "disabled", function( assert ) {
- expect( 8 );
+QUnit.test( "disabled", function( assert ) {
+ assert.expect( 8 );
var count = 0;
element = $( "#slider1" ).slider();
@@ -22,28 +23,28 @@ test( "disabled", function( assert ) {
// Enabled
assert.lacksClasses( element, "ui-slider-disabled" );
- equal( element.slider( "option", "disabled" ), false, "is not disabled" );
+ assert.equal( element.slider( "option", "disabled" ), false, "is not disabled" );
handle().simulate( "drag", { dx: 10 } );
- equal( count, 1, "slider moved" );
+ assert.equal( count, 1, "slider moved" );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal( count, 2, "slider moved" );
+ assert.equal( count, 2, "slider moved" );
// Disabled
element.slider( "option", "disabled", true );
assert.hasClasses( element, "ui-slider-disabled" );
- equal( element.slider( "option", "disabled" ), true, "is disabled" );
+ assert.equal( element.slider( "option", "disabled" ), true, "is disabled" );
handle().simulate( "drag", { dx: 10 } );
- equal( count, 2, "slider did not move" );
+ assert.equal( count, 2, "slider did not move" );
handle().simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equal( count, 2, "slider did not move" );
+ assert.equal( count, 2, "slider did not move" );
} );
-test( "max", function() {
- expect( 7 );
+QUnit.test( "max", function( assert ) {
+ assert.expect( 7 );
element = $( "<div></div>" );
options = {
@@ -55,8 +56,8 @@ test( "max", function() {
};
element.slider( options );
- ok( element.slider( "option", "value" ) === options.value, "value option is not contained by max" );
- ok( element.slider( "value" ) === options.max, "value method is contained by max" );
+ assert.ok( element.slider( "option", "value" ) === options.value, "value option is not contained by max" );
+ assert.ok( element.slider( "value" ) === options.max, "value method is contained by max" );
options = {
max: 9,
@@ -67,12 +68,12 @@ test( "max", function() {
};
element.slider( options );
- ok( element.slider( "value" ) === 7, "value method is within max, edge Case" );
+ assert.ok( element.slider( "value" ) === 7, "value method is within max, edge Case" );
options.step = 2;
element.slider( options );
- ok( element.slider( "value" ) === options.max, "value method will max, step is changed" );
+ assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed" );
element.slider( "destroy" );
options = {
@@ -84,7 +85,7 @@ test( "max", function() {
};
element.slider( options );
- ok( element.slider( "value" ) === options.max, "value method will max, step is changed and step is float" );
+ assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed and step is float" );
element.slider( "destroy" );
options = {
@@ -96,18 +97,18 @@ test( "max", function() {
};
element.slider( options );
- ok( element.slider( "value" ) === options.max, "value method will max, step is changed, step is float and max is float" );
+ assert.ok( element.slider( "value" ) === options.max, "value method will max, step is changed, step is float and max is float" );
element.slider( "destroy" );
options.max = 10.749999999;
element.slider( options );
- ok( element.slider( "value" ) === 10.74, "value method will max, step is changed, step is float, max is float and not divisible" );
+ assert.ok( element.slider( "value" ) === 10.74, "value method will max, step is changed, step is float, max is float and not divisible" );
element.slider( "destroy" );
} );
-test( "min", function() {
- expect( 2 );
+QUnit.test( "min", function( assert ) {
+ assert.expect( 2 );
element = $( "<div></div>" );
options = {
@@ -119,14 +120,14 @@ test( "min", function() {
};
element.slider( options );
- ok( element.slider( "option", "value" ) === options.value, "value option is not contained by min" );
- ok( element.slider( "value" ) === options.min, "value method is contained by min" );
+ assert.ok( element.slider( "option", "value" ) === options.value, "value option is not contained by min" );
+ assert.ok( element.slider( "value" ) === options.min, "value method is contained by min" );
element.slider( "destroy" );
} );
-test( "orientation", function( assert ) {
- expect( 14 );
+QUnit.test( "orientation", function( assert ) {
+ assert.expect( 14 );
element = $( "#slider1" );
options = {
@@ -142,8 +143,8 @@ test( "orientation", function( assert ) {
element.slider( options ).slider( "option", "orientation", "horizontal" );
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: %" );
+ assert.equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" );
+ assert.equal( handle()[ 0 ].style.left, percentVal + "%", "horizontal slider handle is positioned with left: %" );
element.slider( "destroy" ) ;
@@ -159,8 +160,8 @@ test( "orientation", function( assert ) {
element.slider( options ).slider( "option", "orientation", "vertical" );
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: %" );
+ assert.equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" );
+ assert.equal( handle()[ 0 ].style.bottom, percentVal + "%", "vertical slider handle is positioned with bottom: %" );
element.slider( "destroy" );
@@ -174,15 +175,15 @@ test( "orientation", function( assert ) {
element.slider( "option", "value", newValue );
element.slider( "option", "orientation", "vertical" );
- equal( element.find( ".ui-slider-range" ).width(), 12,
+ assert.equal( element.find( ".ui-slider-range" ).width(), 12,
"range should occupy all horizontal space after changing orientation to vertical" );
- equal( element.find( ".ui-slider-range" ).height(), rangeSize,
+ assert.equal( element.find( ".ui-slider-range" ).height(), rangeSize,
"range height of vertical slider should be proportional to the value" );
element.slider( "option", "orientation", "horizontal" );
- equal( element.find( ".ui-slider-range " ).height(), 12,
+ assert.equal( element.find( ".ui-slider-range " ).height(), 12,
"range should occupy all vertical space after changing orientation to horizontal" );
- equal( element.find( ".ui-slider-range" ).width(), rangeSize,
+ assert.equal( element.find( ".ui-slider-range" ).width(), rangeSize,
"range width of horizontal slider should be proportional to the value" );
element.slider( "destroy" );
@@ -193,10 +194,10 @@ test( "orientation", function( assert ) {
max: 100
} );
element.slider( "option", { values: [ 60, 70 ] } );
- notEqual( element.find( ".ui-slider-range " ).position().left, 0,
+ assert.notEqual( element.find( ".ui-slider-range " ).position().left, 0,
"range should not pull over to the track's border" );
element.slider( "option", "orientation", "vertical" );
- equal( element.find( ".ui-slider-range " ).position().left, 0,
+ assert.equal( element.find( ".ui-slider-range " ).position().left, 0,
"range should pull over to the track's border" );
element.slider( "destroy" );
@@ -205,27 +206,27 @@ test( "orientation", function( assert ) {
//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 );
+QUnit.test( "step", function( assert ) {
+ assert.expect( 9 );
element = $( "<div></div>" ).slider( {
min: 0,
value: 0,
step: 10,
max: 100
} );
- equal( element.slider( "value" ), 0 );
+ assert.equal( element.slider( "value" ), 0 );
element.slider( "value", 1 );
- equal( element.slider( "value" ), 0 );
+ assert.equal( element.slider( "value" ), 0 );
element.slider( "value", 9 );
- equal( element.slider( "value" ), 10 );
+ assert.equal( element.slider( "value" ), 10 );
element.slider( "value", 11 );
- equal( element.slider( "value" ), 10 );
+ assert.equal( element.slider( "value" ), 10 );
element.slider( "value", 19 );
- equal( element.slider( "value" ), 20 );
+ assert.equal( element.slider( "value" ), 20 );
element = $( "<div></div>" ).slider( {
min: 0,
@@ -236,26 +237,26 @@ test( "step", function() {
element.slider( "value", 0 );
element.slider( "option", "value", 1 );
- equal( element.slider( "value" ), 0 );
+ assert.equal( element.slider( "value" ), 0 );
element.slider( "option", "value", 9 );
- equal( element.slider( "value" ), 0 );
+ assert.equal( element.slider( "value" ), 0 );
element.slider( "option", "value", 11 );
- equal( element.slider( "value" ), 20 );
+ assert.equal( element.slider( "value" ), 20 );
element.slider( "option", "value", 19 );
- equal( element.slider( "value" ), 20 );
+ assert.equal( element.slider( "value" ), 20 );
element.slider( "destroy" );
} );
-//test( "value", function() {
+//Test( "value", function() {
// ok(false, "missing test - untested code is broken code." );
//});
-test( "values", function() {
- expect( 2 );
+QUnit.test( "values", function( assert ) {
+ assert.expect( 2 );
// Testing multiple ranges on the same page, the object reference to the values
// property is preserved via multiple range elements, so updating options.values
@@ -268,7 +269,7 @@ test( "values", function() {
values: [ 25, 75 ]
} );
- notStrictEqual(
+ assert.notStrictEqual(
ranges.eq( 0 ).slider( "instance" ).options.values,
ranges.eq( 1 ).slider( "instance" ).options.values,
"multiple range sliders should not have a reference to the same options.values array"
@@ -276,15 +277,15 @@ test( "values", function() {
ranges.eq( 0 ).slider( "values", 0, 10 );
- notEqual(
+ assert.notEqual(
ranges.eq( 0 ).slider( "values", 0 ),
ranges.eq( 1 ).slider( "values", 0 ),
"the values for multiple sliders should be different"
);
} );
-test( "range", function( assert ) {
- expect( 32 );
+QUnit.test( "range", function( assert ) {
+ assert.expect( 32 );
var range;
// Min
@@ -295,8 +296,8 @@ test( "range", function( assert ) {
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" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle" );
+ assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" );
element.slider( "destroy" );
// Max
@@ -307,8 +308,8 @@ test( "range", function( assert ) {
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" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle" );
+ assert.equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" );
element.slider( "destroy" );
// True
@@ -320,7 +321,7 @@ test( "range", function( assert ) {
} );
range = element.find( ".ui-slider-range" );
- equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
assert.lacksClasses( range, "ui-slider-range-max ui-slider-range-min" );
element.slider( "destroy" );
@@ -332,9 +333,9 @@ test( "range", function( assert ) {
step: 1
} ).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" );
- equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle" );
+ assert.equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" );
+ assert.equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" );
element.slider( "destroy" );
// Change range from max to min
@@ -345,9 +346,9 @@ test( "range", function( assert ) {
step: 1
} ).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" );
- equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle" );
+ assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" );
+ assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" );
element.slider( "destroy" );
// Change range from max to true
@@ -358,13 +359,13 @@ test( "range", function( assert ) {
step: 1
} ).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" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles" );
+ assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" );
+ assert.equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" );
+ assert.equal( element.slider( "option", "value" ), 0, "option value" );
+ assert.equal( element.slider( "value" ), 1, "value" );
+ assert.deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
+ assert.deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
element.slider( "destroy" );
// Change range from true to min
@@ -375,13 +376,13 @@ test( "range", function( assert ) {
step: 1
} ).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( "option", "values" ), null, "values" );
- deepEqual( element.slider( "values" ), [], "values" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle" );
+ assert.equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" );
+ assert.equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" );
+ assert.equal( element.slider( "option", "value" ), 1, "value" );
+ assert.equal( element.slider( "value" ), 1, "value" );
+ assert.equal( element.slider( "option", "values" ), null, "values" );
+ assert.deepEqual( element.slider( "values" ), [], "values" );
element.slider( "destroy" );
// Change range from true to false
@@ -391,12 +392,12 @@ test( "range", function( assert ) {
max: 10,
step: 1
} ).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" );
+ assert.equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from true to false, both handles remain" );
+ assert.equal( element.find( ".ui-slider-range" ).length, 0, "range switch from true to false" );
+ assert.equal( element.slider( "option", "value" ), 0, "option value" );
+ assert.equal( element.slider( "value" ), 1, "value" );
+ assert.deepEqual( element.slider( "option", "values" ), [ 1, 1 ], "option values" );
+ assert.deepEqual( element.slider( "values" ), [ 1, 1 ], "values" );
element.slider( "destroy" );
} );