diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/slider/slider_methods.js | 20 | ||||
-rw-r--r-- | tests/unit/slider/slider_options.js | 23 |
2 files changed, 19 insertions, 24 deletions
diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index ce26620e2..cf64e3b63 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -30,34 +30,30 @@ test( "destroy", function() { }); }); -test( "enable", function() { - expect( 5 ); +test( "enable", function( assert ) { + expect( 3 ); var element, expected = $( "<div></div>" ).slider(), actual = expected.slider( "enable" ); equal(actual, expected, "enable is chainable" ); element = $( "<div></div>" ).slider({ disabled: true }); - ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class before enable method call" ); - ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class before enable method call" ); + assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" ); element.slider( "enable" ); - ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class after enable method call" ); - ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class after enable method call" ); + assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" ); }); -test( "disable", function() { - expect( 6 ); +test( "disable", function( assert ) { + expect( 4 ); var element, expected = $( "<div></div>" ).slider(), actual = expected.slider( "disable" ); equal(actual, expected, "disable is chainable" ); element = $( "<div></div>" ).slider({ disabled: false }); - ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class before disabled method call" ); - ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class before disable method call" ); + assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" ); element.slider( "disable" ); - ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); - ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); + 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" ); }); diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 2badcc566..dedfe78d3 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -8,7 +8,7 @@ function handle() { module( "slider: options" ); -test( "disabled", function(){ +test( "disabled", function( assert ){ expect( 8 ); var count = 0; @@ -18,7 +18,7 @@ test( "disabled", function(){ }); // enabled - ok( !element.hasClass( "ui-slider-disabled" ), "no disabled class" ); + assert.lacksClasses( element, "ui-slider-disabled" ); equal( element.slider( "option", "disabled" ), false , "is not disabled" ); handle().simulate( "drag", { dx: 10 } ); @@ -29,7 +29,7 @@ test( "disabled", function(){ // disabled element.slider( "option", "disabled", true ); - ok( element.hasClass( "ui-slider-disabled" ), "has disabled class" ); + assert.hasClasses( element, "ui-slider-disabled" ); equal( element.slider( "option", "disabled" ), true, "is disabled" ); handle().simulate( "drag", { dx: 10 } ); @@ -105,7 +105,7 @@ test( "min", function() { }); -test( "orientation", function() { +test( "orientation", function( assert ) { expect( 8 ); element = $( "#slider1" ); @@ -119,8 +119,8 @@ test( "orientation", function() { var percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; element.slider( options ).slider( "option", "orientation", "horizontal" ); - ok( element.is( ".ui-slider-horizontal" ), "horizontal slider has class .ui-slider-horizontal" ); - ok( !element.is( ".ui-slider-vertical" ), "horizontal slider does not have class .ui-slider-vertical" ); + 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: %" ); @@ -136,8 +136,8 @@ test( "orientation", function() { percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100; element.slider( options ).slider( "option", "orientation", "vertical" ); - ok( element.is( ".ui-slider-vertical" ), "vertical slider has class .ui-slider-vertical" ); - ok( !element.is( ".ui-slider-horizontal" ), "vertical slider does not have class .ui-slider-horizontal" ); + 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: %" ); @@ -226,8 +226,8 @@ test( "values", function() { ); }); -test( "range", function() { - expect( 33 ); +test( "range", function( assert ) { + expect( 32 ); var range; // min @@ -264,8 +264,7 @@ test( "range", function() { range = element.find( ".ui-slider-range" ); equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" ); - ok( !range.is( ".ui-slider-range-min" ), "range true" ); - ok( !range.is( ".ui-slider-range-max" ), "range true" ); + assert.lacksClasses( range, "ui-slider-range-max ui-slider-range-min" ); element.slider( "destroy" ); // Change range from min to max |