Skip to content
Permalink
Browse files

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

  • Loading branch information
arschmitz committed Jan 30, 2015
1 parent 8f26f0a commit f7645783bf6c224f75a796ed146154559152e4cb
Showing with 19 additions and 16 deletions.
  1. +7 −8 tests/unit/spinner/spinner_methods.js
  2. +12 −8 tests/unit/spinner/spinner_options.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 );
@@ -4,30 +4,34 @@ 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: {
down: "custom-down",
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() {

0 comments on commit f764578

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