Skip to content
Permalink
Browse files

Slider: Use new has/lacksClasses assertions for all class checks

  • Loading branch information
arschmitz committed Jan 30, 2015
1 parent 8eb29fd commit cba7fd546689835297aae40e69636f653a9e2dba
Showing with 19 additions and 24 deletions.
  1. +8 −12 tests/unit/slider/slider_methods.js
  2. +11 −12 tests/unit/slider/slider_options.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" );
});

@@ -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

0 comments on commit cba7fd5

Please sign in to comment.
You can’t perform that action at this time.