Debian Codegraph @

tests/unit/dialog/deprecated.js

raw symbols SCIP
1 define( [
2 "qunit",
3 "jquery",
4 "lib/helper",
5 "ui/widgets/dialog"
6 ], function( QUnit, $, helper ) {
7 "use strict";
8
9 QUnit.module( "dialog (deprecated): options", { afterEach: helper.moduleAfterEach } );
10
11 QUnit.test( "dialogClass", function( assert ) {
12 assert.expect( 5 );
13
14 var element = $( "<div>" ).dialog(),
15 widget = element.dialog( "widget" );
16 assert.lacksClasses( widget, "foo", "dialogClass not specified. class not added" );
17 element.remove();
18
19 element = $( "<div>" ).dialog( { dialogClass: "foo" } );
20 widget = element.dialog( "widget" );
21 assert.hasClasses( widget, "foo", "dialogClass in init, foo class added" );
22 element.dialog( "option", "dialogClass", "foobar" );
23 assert.lacksClasses( widget, "foo", "dialogClass changed, previous one was removed" );
24 assert.hasClasses( widget, "foobar", "dialogClass changed, new one was added" );
25 element.remove();
26
27 element = $( "<div>" ).dialog( { dialogClass: "foo bar" } );
28 widget = element.dialog( "widget" );
29 assert.hasClasses( widget, "foo bar", "dialogClass in init, two classes." );
30 element.remove();
31 } );
32
33 QUnit.test( "buttons - deprecated options", function( assert ) {
34 assert.expect( 7 );
35
36 var buttons,
37 element = $( "<div></div>" ).dialog( {
38 buttons: [
39 {
40 html: "a button",
41 "class": "additional-class",
42 id: "my-button-id",
43 click: function() {
44 assert.equal( this, element[ 0 ], "correct context" );
45 },
46 icons: { primary: "ui-icon-cancel" },
47 text: false
48 }
49 ]
50 } );
51
52 buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
53 assert.equal( buttons.length, 1, "correct number of buttons" );
54 assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
55 assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" );
56 assert.hasClasses( buttons, "additional-class" );
57 assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
58 assert.equal( buttons.button( "option", "showLabel" ), false );
59 buttons.trigger( "click" );
60
61 element.remove();
62 } );
63 } );