mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Slider: Use new has/lacksClasses assertions for all class checks
This commit is contained in:
parent
8eb29fd90c
commit
cba7fd5466
@ -30,34 +30,30 @@ test( "destroy", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "enable", function() {
|
test( "enable", function( assert ) {
|
||||||
expect( 5 );
|
expect( 3 );
|
||||||
var element,
|
var element,
|
||||||
expected = $( "<div></div>" ).slider(),
|
expected = $( "<div></div>" ).slider(),
|
||||||
actual = expected.slider( "enable" );
|
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 });
|
||||||
ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class before enable method call" );
|
assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" );
|
||||||
ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class before enable method call" );
|
|
||||||
element.slider( "enable" );
|
element.slider( "enable" );
|
||||||
ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class after enable method call" );
|
assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" );
|
||||||
ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class after enable method call" );
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "disable", function() {
|
test( "disable", function( assert ) {
|
||||||
expect( 6 );
|
expect( 4 );
|
||||||
var element,
|
var element,
|
||||||
expected = $( "<div></div>" ).slider(),
|
expected = $( "<div></div>" ).slider(),
|
||||||
actual = expected.slider( "disable" );
|
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 });
|
||||||
ok( !element.hasClass( "ui-state-disabled" ), "slider does not have ui-state-disabled class before disabled method call" );
|
assert.lacksClasses( element, "ui-state-disabled ui-slider-disabled" );
|
||||||
ok( !element.hasClass( "ui-slider-disabled" ), "slider does not have ui-slider-disabled class before disable method call" );
|
|
||||||
element.slider( "disable" );
|
element.slider( "disable" );
|
||||||
ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" );
|
assert.hasClasses( element, "ui-state-disabled ui-slider-disabled" );
|
||||||
ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" );
|
|
||||||
ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" );
|
ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ function handle() {
|
|||||||
|
|
||||||
module( "slider: options" );
|
module( "slider: options" );
|
||||||
|
|
||||||
test( "disabled", function(){
|
test( "disabled", function( assert ){
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ test( "disabled", function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
// enabled
|
// 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" );
|
equal( element.slider( "option", "disabled" ), false , "is not disabled" );
|
||||||
|
|
||||||
handle().simulate( "drag", { dx: 10 } );
|
handle().simulate( "drag", { dx: 10 } );
|
||||||
@ -29,7 +29,7 @@ test( "disabled", function(){
|
|||||||
|
|
||||||
// disabled
|
// disabled
|
||||||
element.slider( "option", "disabled", true );
|
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" );
|
equal( element.slider( "option", "disabled" ), true, "is disabled" );
|
||||||
|
|
||||||
handle().simulate( "drag", { dx: 10 } );
|
handle().simulate( "drag", { dx: 10 } );
|
||||||
@ -105,7 +105,7 @@ test( "min", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "orientation", function() {
|
test( "orientation", function( assert ) {
|
||||||
expect( 8 );
|
expect( 8 );
|
||||||
element = $( "#slider1" );
|
element = $( "#slider1" );
|
||||||
|
|
||||||
@ -119,8 +119,8 @@ test( "orientation", function() {
|
|||||||
var percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
var percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
||||||
|
|
||||||
element.slider( options ).slider( "option", "orientation", "horizontal" );
|
element.slider( options ).slider( "option", "orientation", "horizontal" );
|
||||||
ok( element.is( ".ui-slider-horizontal" ), "horizontal slider has class .ui-slider-horizontal" );
|
assert.hasClasses( element, "ui-slider-horizontal" );
|
||||||
ok( !element.is( ".ui-slider-vertical" ), "horizontal slider does not have class .ui-slider-vertical" );
|
assert.lacksClasses( element, "ui-slider-vertical" );
|
||||||
equal( element.find( ".ui-slider-handle" )[ 0 ].style.bottom, "", "CSS bottom reset" );
|
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: %" );
|
||||||
|
|
||||||
@ -136,8 +136,8 @@ test( "orientation", function() {
|
|||||||
percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
percentVal = ( options.value - options.min ) / ( options.max - options.min ) * 100;
|
||||||
|
|
||||||
element.slider( options ).slider( "option", "orientation", "vertical" );
|
element.slider( options ).slider( "option", "orientation", "vertical" );
|
||||||
ok( element.is( ".ui-slider-vertical" ), "vertical slider has class .ui-slider-vertical" );
|
assert.hasClasses( element, "ui-slider-vertical" );
|
||||||
ok( !element.is( ".ui-slider-horizontal" ), "vertical slider does not have class .ui-slider-horizontal" );
|
assert.lacksClasses( element, "ui-slider-horizontal" );
|
||||||
equal( element.find( ".ui-slider-handle" )[ 0 ].style.left, "", "CSS left reset" );
|
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: %" );
|
||||||
|
|
||||||
@ -226,8 +226,8 @@ test( "values", function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "range", function() {
|
test( "range", function( assert ) {
|
||||||
expect( 33 );
|
expect( 32 );
|
||||||
var range;
|
var range;
|
||||||
|
|
||||||
// min
|
// min
|
||||||
@ -264,8 +264,7 @@ test( "range", function() {
|
|||||||
|
|
||||||
range = element.find( ".ui-slider-range" );
|
range = element.find( ".ui-slider-range" );
|
||||||
equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
|
equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles" );
|
||||||
ok( !range.is( ".ui-slider-range-min" ), "range true" );
|
assert.lacksClasses( range, "ui-slider-range-max ui-slider-range-min" );
|
||||||
ok( !range.is( ".ui-slider-range-max" ), "range true" );
|
|
||||||
element.slider( "destroy" );
|
element.slider( "destroy" );
|
||||||
|
|
||||||
// Change range from min to max
|
// Change range from min to max
|
||||||
|
Loading…
Reference in New Issue
Block a user