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

This commit is contained in:
Alexander Schmitz 2015-01-30 09:57:04 -05:00
parent 415675eca1
commit a9fa490418
5 changed files with 18 additions and 21 deletions

View File

@ -8,7 +8,7 @@ TestHelpers.commonWidgetTests( "dialog", {
"ui-dialog-titlebar": "ui-corner-all"
},
closeOnEscape: true,
closeText: "close",
closeText: "Close",
dialogClass: "",
disabled: false,
draggable: true,

View File

@ -30,7 +30,7 @@
});
</script>
<script src="dialog_common_derecated.js"></script>
<script src="dialog_common_deprecated.js"></script>
<script src="dialog_core.js"></script>
<script src="dialog_events.js"></script>
<script src="dialog_methods.js"></script>

View File

@ -2,26 +2,25 @@
module( "dialog (deprecated): options" );
test( "dialogClass", function() {
expect( 6 );
test( "dialogClass", function( assert ) {
expect( 5 );
var element = $( "<div>" ).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 = $( "<div>" ).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 = $( "<div>" ).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();
});

View File

@ -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 = $( "<div></div>" ).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" );
});

View File

@ -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();