2015-04-07 00:23:50 +00:00
|
|
|
define( [
|
2016-04-03 16:10:09 +00:00
|
|
|
"qunit",
|
2015-04-07 00:23:50 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"lib/helper",
|
2015-07-15 01:59:10 +00:00
|
|
|
"ui/widgets/dialog"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, helper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2014-12-03 16:23:59 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
QUnit.module( "dialog (deprecated): options", { afterEach: helper.moduleAfterEach } );
|
2014-12-03 16:23:59 +00:00
|
|
|
|
2016-04-03 16:10:09 +00:00
|
|
|
QUnit.test( "dialogClass", function( assert ) {
|
|
|
|
assert.expect( 5 );
|
2014-12-03 16:23:59 +00:00
|
|
|
|
|
|
|
var element = $( "<div>" ).dialog(),
|
|
|
|
widget = element.dialog( "widget" );
|
2015-01-30 14:57:04 +00:00
|
|
|
assert.lacksClasses( widget, "foo", "dialogClass not specified. class not added" );
|
2014-12-03 16:23:59 +00:00
|
|
|
element.remove();
|
|
|
|
|
2015-08-24 12:59:54 +00:00
|
|
|
element = $( "<div>" ).dialog( { dialogClass: "foo" } );
|
2014-12-03 16:23:59 +00:00
|
|
|
widget = element.dialog( "widget" );
|
2015-01-30 14:57:04 +00:00
|
|
|
assert.hasClasses( widget, "foo", "dialogClass in init, foo class added" );
|
2014-12-03 16:23:59 +00:00
|
|
|
element.dialog( "option", "dialogClass", "foobar" );
|
2015-01-30 14:57:04 +00:00
|
|
|
assert.lacksClasses( widget, "foo", "dialogClass changed, previous one was removed" );
|
|
|
|
assert.hasClasses( widget, "foobar", "dialogClass changed, new one was added" );
|
2014-12-03 16:23:59 +00:00
|
|
|
element.remove();
|
|
|
|
|
2015-08-24 12:59:54 +00:00
|
|
|
element = $( "<div>" ).dialog( { dialogClass: "foo bar" } );
|
2014-12-03 16:23:59 +00:00
|
|
|
widget = element.dialog( "widget" );
|
2015-01-30 14:57:04 +00:00
|
|
|
assert.hasClasses( widget, "foo bar", "dialogClass in init, two classes." );
|
2014-12-03 16:23:59 +00:00
|
|
|
element.remove();
|
2015-08-24 12:59:54 +00:00
|
|
|
} );
|
2014-12-03 16:23:59 +00:00
|
|
|
|
2016-07-25 12:16:13 +00:00
|
|
|
QUnit.test( "buttons - deprecated options", function( assert ) {
|
|
|
|
assert.expect( 7 );
|
|
|
|
|
|
|
|
var buttons,
|
|
|
|
element = $( "<div></div>" ).dialog( {
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
html: "a button",
|
|
|
|
"class": "additional-class",
|
|
|
|
id: "my-button-id",
|
|
|
|
click: function() {
|
|
|
|
assert.equal( this, element[ 0 ], "correct context" );
|
|
|
|
},
|
|
|
|
icons: { primary: "ui-icon-cancel" },
|
|
|
|
text: false
|
|
|
|
}
|
|
|
|
]
|
|
|
|
} );
|
|
|
|
|
|
|
|
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
|
|
|
|
assert.equal( buttons.length, 1, "correct number of buttons" );
|
|
|
|
assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
|
2019-12-08 21:23:08 +00:00
|
|
|
assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" );
|
2016-07-25 12:16:13 +00:00
|
|
|
assert.hasClasses( buttons, "additional-class" );
|
|
|
|
assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
|
|
|
|
assert.equal( buttons.button( "option", "showLabel" ), false );
|
|
|
|
buttons.trigger( "click" );
|
|
|
|
|
|
|
|
element.remove();
|
|
|
|
} );
|
2015-04-07 00:23:50 +00:00
|
|
|
} );
|