From: Alexander Schmitz Date: Fri, 30 Jan 2015 15:59:50 +0000 (-0500) Subject: Spinner: Use new has/lacksClasses assertions for all class checks X-Git-Tag: 1.12.0-beta.1~386 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f7645783bf6c224f75a796ed146154559152e4cb;p=jquery-ui.git Spinner: Use new has/lacksClasses assertions for all class checks --- diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index cc4bc5a16..61ff21d1c 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -11,17 +11,16 @@ test( "destroy", function() { }); }); -test( "disable", function() { - expect( 16 ); +test( "disable", function( assert ) { + expect( 15 ); var element = $( "#spin" ).val( 2 ).spinner(), wrapper = $( "#spin" ).spinner( "widget" ); - ok( !wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper does not have ui-spinner-disabled class" ); + assert.lacksClasses( wrapper, "ui-spinner-disabled" ); ok( !element.is( ":disabled" ), "before: input does not have disabled attribute" ); element.spinner( "disable" ); - ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); - ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" ); + assert.hasClasses( wrapper, "ui-state-disabled ui-spinner-disabled" ); ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" ); ok( element.is( ":disabled"), "after: input has disabled attribute" ); @@ -56,17 +55,17 @@ test( "disable", function() { equal( 7, element.val(), "script - pageDown 1 page changes value" ); }); -test( "enable", function() { +test( "enable", function( assert ) { expect( 5 ); var element = $( "#spin" ).val( 1 ).spinner({ disabled: true }), wrapper = element.spinner( "widget" ); - ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" ); + assert.hasClasses( wrapper, "ui-spinner-disabled" ); ok( element.is( ":disabled" ), "before: input has disabled attribute" ); element.spinner( "enable" ); - ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" ); + assert.lacksClasses( wrapper, "ui-spinner-disabled" ); ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" ); simulateKeyDownUp( element, $.ui.keyCode.UP ); diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 65bbd2602..160b600c6 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -4,21 +4,25 @@ module( "spinner: options" ); // culture is tested after numberFormat, since it depends on numberFormat -test( "icons: default ", function() { +test( "icons: default ", function( assert ) { expect( 4 ); var element = $( "#spin" ).val( 0 ).spinner(); - equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" ); - equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" ); + assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ), + "ui-icon ui-icon-triangle-1-n" ); + assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ), + "ui-icon ui-icon-triangle-1-s" ); element.spinner( "option", "icons", { up: "ui-icon-caret-1-n", down: "ui-icon-caret-1-s" }); - equal( element.spinner( "widget" ).find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-caret-1-n" ); - equal( element.spinner( "widget" ).find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-caret-1-s" ); + assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:first" ), + "ui-icon ui-icon-caret-1-n" ); + assert.hasClasses( element.spinner( "widget" ).find( ".ui-icon:last" ), + "ui-icon ui-icon-caret-1-s" ); }); -test( "icons: custom ", function() { +test( "icons: custom ", function( assert ) { expect( 2 ); var element = $( "#spin" ).val( 0 ).spinner({ icons: { @@ -26,8 +30,8 @@ test( "icons: custom ", function() { up: "custom-up" } }).spinner( "widget" ); - equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon custom-up" ); - equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon custom-down" ); + assert.hasClasses( element.find( ".ui-icon:first" ), "ui-icon custom-up" ); + assert.hasClasses( element.find( ".ui-icon:last" ), "ui-icon custom-down" ); }); test( "incremental, false", function() {