From a9fa490418c911ff8a170c5d2e87e5dbc3be3ea3 Mon Sep 17 00:00:00 2001 From: Alexander Schmitz Date: Fri, 30 Jan 2015 09:57:04 -0500 Subject: [PATCH] Dialog: Use new has/lacksClasses assertions for all class checks --- tests/unit/dialog/dialog_common_deprecated.js | 2 +- tests/unit/dialog/dialog_deprecated.html | 2 +- tests/unit/dialog/dialog_deprecated.js | 15 +++++++-------- tests/unit/dialog/dialog_methods.js | 7 +++---- tests/unit/dialog/dialog_options.js | 13 ++++++------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/unit/dialog/dialog_common_deprecated.js b/tests/unit/dialog/dialog_common_deprecated.js index 9ecf6a459..30658696e 100644 --- a/tests/unit/dialog/dialog_common_deprecated.js +++ b/tests/unit/dialog/dialog_common_deprecated.js @@ -8,7 +8,7 @@ TestHelpers.commonWidgetTests( "dialog", { "ui-dialog-titlebar": "ui-corner-all" }, closeOnEscape: true, - closeText: "close", + closeText: "Close", dialogClass: "", disabled: false, draggable: true, diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html index b26c38e9a..5bcdf75e5 100644 --- a/tests/unit/dialog/dialog_deprecated.html +++ b/tests/unit/dialog/dialog_deprecated.html @@ -30,7 +30,7 @@ }); - + diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js index 6a26c229e..55c180457 100644 --- a/tests/unit/dialog/dialog_deprecated.js +++ b/tests/unit/dialog/dialog_deprecated.js @@ -2,26 +2,25 @@ module( "dialog (deprecated): options" ); -test( "dialogClass", function() { - expect( 6 ); +test( "dialogClass", function( assert ) { + expect( 5 ); var element = $( "
" ).dialog(), widget = element.dialog( "widget" ); - equal( widget.is( ".foo" ), false, "dialogClass not specified. class not added" ); + assert.lacksClasses( widget, "foo", "dialogClass not specified. class not added" ); element.remove(); element = $( "
" ).dialog({ dialogClass: "foo" }); widget = element.dialog( "widget" ); - equal( widget.is( ".foo" ), true, "dialogClass in init, foo class added" ); + assert.hasClasses( widget, "foo", "dialogClass in init, foo class added" ); element.dialog( "option", "dialogClass", "foobar" ); - equal( widget.is( ".foo" ), false, "dialogClass changed, previous one was removed" ); - equal( widget.is( ".foobar" ), true, "dialogClass changed, new one was added" ); + assert.lacksClasses( widget, "foo", "dialogClass changed, previous one was removed" ); + assert.hasClasses( widget, "foobar", "dialogClass changed, new one was added" ); element.remove(); element = $( "
" ).dialog({ dialogClass: "foo bar" }); widget = element.dialog( "widget" ); - equal( widget.is( ".foo" ), true, "dialogClass in init, two classes. foo class added" ); - equal( widget.is( ".bar" ), true, "dialogClass in init, two classes. bar class added" ); + assert.hasClasses( widget, "foo bar", "dialogClass in init, two classes." ); element.remove(); }); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index ea4a7002a..c012f80a5 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -100,13 +100,12 @@ test("#4980: Destroy should place element back in original DOM position", functi ok($.contains(container[0], modal[0]), "dialog(destroy) should place element back in original DOM position"); }); -test( "enable/disable disabled", function() { - expect( 4 ); +test( "enable/disable disabled", function( assert ) { + expect( 3 ); var element = $( "
" ).dialog(); element.dialog( "disable" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); - ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); - ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" ); + assert.lacksClasses( element, "ui-dialog-disabled ui-state-disabled" ); ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" ); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index d9920b9fc..6cc309ca4 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -78,7 +78,7 @@ test("autoOpen", function() { element.remove(); }); -test("buttons", function() { +test("buttons", function( assert ) { expect(21); var btn, i, newButtons, @@ -105,8 +105,8 @@ test("buttons", function() { i++; }); - ok(btn.parent().hasClass("ui-dialog-buttonset"), "buttons in container"); - ok(element.parent().hasClass("ui-dialog-buttons"), "dialog wrapper adds class about having buttons"); + assert.hasClasses( btn.parent(), "ui-dialog-buttonset" ); + assert.hasClasses( element.parent(), "ui-dialog-buttons" ); btn.trigger("click"); @@ -136,12 +136,11 @@ test("buttons", function() { btn = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); equal(btn.length, 0, "all buttons have been removed"); equal(element.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); - equal(element.parent().hasClass("ui-dialog-buttons"), false, "dialog wrapper removes class about having buttons"); - + assert.lacksClasses( element.parent(), "ui-dialog-buttons" ); element.remove(); }); -test("buttons - advanced", function() { +test("buttons - advanced", function( assert ) { expect( 7 ); var buttons, @@ -166,7 +165,7 @@ test("buttons - advanced", function() { equal(buttons.length, 1, "correct number of buttons"); equal(buttons.attr("id"), "my-button-id", "correct id"); equal(buttons.text(), "a button", "correct label"); - ok(buttons.hasClass("additional-class"), "additional classes added"); + assert.hasClasses( buttons, "additional-class" ); deepEqual( buttons.button("option", "icons"), { primary: "ui-icon-cancel", secondary: null } ); equal( buttons.button( "option", "text" ), false ); buttons.click(); -- 2.39.5