Skip to content

Commit 290f0e7

Browse files
committed
Controlgroup: Shift to use no globals
1 parent e089b1d commit 290f0e7

File tree

3 files changed

+46
-43
lines changed

3 files changed

+46
-43
lines changed

tests/unit/controlgroup/core.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
define( [
2+
"qunit",
23
"jquery",
34
"ui/widgets/controlgroup",
45
"ui/widgets/checkboxradio",
56
"ui/widgets/selectmenu",
67
"ui/widgets/button"
7-
], function( $ ) {
8+
], function( QUnit, $ ) {
89

9-
module( "Controlgroup: Core" );
10+
QUnit.module( "Controlgroup: Core" );
1011

11-
test( "selectmenu: open/close corners", function( assert ) {
12-
expect( 12 );
12+
QUnit.test( "selectmenu: open/close corners", function( assert ) {
13+
assert.expect( 12 );
1314
var element = $( ".controlgroup" ).controlgroup(),
1415
selects = element.find( "select" ),
1516
selectButton = selects.eq( 0 ).selectmenu( "widget" );
@@ -64,8 +65,8 @@ test( "selectmenu: open/close corners", function( assert ) {
6465
"vertical: Last selectmenu gets ui-corner-bottom when closed" );
6566
} );
6667

67-
test( "selectmenu: controlgroupLabel", function( assert ) {
68-
expect( 2 );
68+
QUnit.test( "selectmenu: controlgroupLabel", function( assert ) {
69+
assert.expect( 2 );
6970
var element = $( ".controlgroup" ).controlgroup();
7071
var label = element.find( ".ui-controlgroup-label" );
7172

tests/unit/controlgroup/methods.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
define( [
2+
"qunit",
23
"jquery",
34
"ui/widgets/controlgroup",
45
"ui/widgets/checkboxradio",
56
"ui/widgets/selectmenu",
67
"ui/widgets/button"
7-
], function( $ ) {
8+
], function( QUnit, $ ) {
89

9-
module( "Controlgroup: methods" );
10+
QUnit.module( "Controlgroup: methods" );
1011

11-
test( "destroy", function( assert ) {
12-
expect( 1 );
12+
QUnit.test( "destroy", function( assert ) {
13+
assert.expect( 1 );
1314
assert.domEqual( ".controlgroup", function() {
1415
$( ".controlgroup" ).controlgroup().controlgroup( "destroy" );
1516
} );
1617
} );
1718

18-
test( "disable", function( assert ) {
19-
expect( 2 );
19+
QUnit.test( "disable", function( assert ) {
20+
assert.expect( 2 );
2021
var element = $( ".controlgroup" ).controlgroup().controlgroup( "disable" );
2122
assert.lacksClasses( element, "ui-state-disabled",
2223
"The widget does not get the disabled class, because we disable each child widget" );
23-
strictEqual( element.find( ".ui-state-disabled" ).length, 6,
24+
assert.strictEqual( element.find( ".ui-state-disabled" ).length, 6,
2425
"Child widgets are disabled" );
2526
} );
2627

27-
test( "enable", function( assert ) {
28-
expect( 2 );
28+
QUnit.test( "enable", function( assert ) {
29+
assert.expect( 2 );
2930
var element = $( ".controlgroup" ).controlgroup().controlgroup( "enable" );
3031
assert.lacksClasses( element, "ui-state-disabled",
3132
"ui-state-disabled is not present on widget after enabling" );
32-
strictEqual( element.find( "ui-state-disabled" ).length, 0,
33+
assert.strictEqual( element.find( "ui-state-disabled" ).length, 0,
3334
"Child widgets are disabled" );
3435
} );
3536

@@ -59,16 +60,16 @@ $.each( tests, function( widget, html ) {
5960
// Check in both horizontal and vertical orientations
6061
$.each( orientations, function( name, classes ) {
6162

62-
test( "refresh: " + widget + ": " + name, function( assert ) {
63-
expect( 41 );
63+
QUnit.test( "refresh: " + widget + ": " + name, function( assert ) {
64+
assert.expect( 41 );
6465

6566
var i, control, currentClasses,
6667
controls = [],
6768
element = $( "<div>" ).controlgroup( {
6869
direction: name
6970
} ).appendTo( "body" );
7071

71-
// checks the elements with in the controlgroup against the expected class list
72+
// Checks the elements with in the controlgroup against the expected class list
7273
function checkCornerClasses( classList ) {
7374
for ( var j = 0; j < 4; j++ ) {
7475
if ( classList[ j ] ) {
@@ -118,14 +119,14 @@ $.each( tests, function( widget, html ) {
118119
// Refresh the controlgroup now that its populated
119120
element.controlgroup( "refresh" );
120121
for ( i = 0; i < 4; i++ ) {
121-
strictEqual( controls[ i ].is( ":ui-" + widget ), true,
122+
assert.strictEqual( controls[ i ].is( ":ui-" + widget ), true,
122123
name + ": " + widget + " " + i + ": is a " + widget + " widget" );
123124
}
124125

125126
// Check that we have the right classes
126127
checkCornerClasses( classes );
127128

128-
// hide each element and then check its classes
129+
// Hide each element and then check its classes
129130
iterateHidden( true );
130131

131132
// Set the exclude option to false so we no longer care about hidden
@@ -141,7 +142,7 @@ $.each( tests, function( widget, html ) {
141142

142143
assert.hasClasses( controls[ 0 ][ widget ]( "widget" ), "ui-state-disabled" );
143144

144-
// remove the controlgroup before we start the next set
145+
// Remove the controlgroup before we start the next set
145146
element.remove();
146147
} );
147148
} );

tests/unit/controlgroup/options.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
define( [
2+
"qunit",
23
"jquery",
34
"ui/widgets/controlgroup",
45
"ui/widgets/checkboxradio",
56
"ui/widgets/selectmenu",
67
"ui/widgets/button"
7-
], function( $ ) {
8+
], function( QUnit, $ ) {
89

9-
module( "Controlgroup: options" );
10+
QUnit.module( "Controlgroup: options" );
1011

11-
test( "disabled", function( assert ) {
12-
expect( 4 );
12+
QUnit.test( "disabled", function( assert ) {
13+
assert.expect( 4 );
1314
var element = $( ".controlgroup" ).controlgroup().controlgroup( "option", "disabled", true );
1415
assert.lacksClasses( element, "ui-state-disabled" );
15-
equal( element.find( ".ui-state-disabled" ).length, 6, "Child widgets are disabled" );
16+
assert.equal( element.find( ".ui-state-disabled" ).length, 6, "Child widgets are disabled" );
1617

1718
element.controlgroup( "option", "disabled", false );
1819
assert.lacksClasses( element, "ui-state-disabled" );
19-
strictEqual( element.find( ".ui-state-disabled" ).length, 0, "Child widgets are not disabled" );
20+
assert.strictEqual( element.find( ".ui-state-disabled" ).length, 0, "Child widgets are not disabled" );
2021

2122
} );
2223

23-
test( "items - null", function() {
24-
expect( 2 );
24+
QUnit.test( "items - null", function( assert ) {
25+
assert.expect( 2 );
2526
var element = $( ".controlgroup" ).controlgroup( {
2627
items: {
2728
"button": null,
@@ -30,24 +31,24 @@ test( "items - null", function() {
3031
}
3132
} );
3233

33-
strictEqual( element.children( ".ui-button" ).length, 0,
34+
assert.strictEqual( element.children( ".ui-button" ).length, 0,
3435
"Child widgets are not called when selector is null" );
3536

3637
element.controlgroup( "option", "items", {
3738
"button": "button"
3839
} );
39-
strictEqual( element.children( ".ui-button" ).length, 2,
40+
assert.strictEqual( element.children( ".ui-button" ).length, 2,
4041
"Correct child widgets are called when selector is updated" );
4142
} );
4243

43-
test( "items: custom selector", function() {
44-
expect( 1 );
44+
QUnit.test( "items: custom selector", function( assert ) {
45+
assert.expect( 1 );
4546
var element = $( ".controlgroup" ).controlgroup( {
4647
items: {
4748
"button": ".button"
4849
}
4950
} );
50-
strictEqual( element.children( ".ui-button" ).length, 4,
51+
assert.strictEqual( element.children( ".ui-button" ).length, 4,
5152
"Correct child widgets are called when custom selector used" );
5253
} );
5354

@@ -60,22 +61,22 @@ $.widget( "ui.test", {
6061
refresh: $.noop
6162
} );
6263

63-
test( "items: custom widget", function() {
64-
expect( 2 );
64+
QUnit.test( "items: custom widget", function( assert ) {
65+
assert.expect( 2 );
6566
var element = $( ".controlgroup" ).controlgroup( {
6667
items: {
6768
"test": ".test"
6869
}
6970
} );
7071

71-
strictEqual( element.children( ".ui-button" ).length, 7,
72+
assert.strictEqual( element.children( ".ui-button" ).length, 7,
7273
"Correct child widgets are called when custom selector used" );
73-
strictEqual( element.children( ".ui-test" ).length, 1,
74+
assert.strictEqual( element.children( ".ui-test" ).length, 1,
7475
"Custom widget called" );
7576
} );
7677

77-
test( "onlyVisible", function( assert ) {
78-
expect( 4 );
78+
QUnit.test( "onlyVisible", function( assert ) {
79+
assert.expect( 4 );
7980
var element = $( ".controlgroup" ).controlgroup( {
8081
onlyVisible: false
8182
} ),
@@ -91,8 +92,8 @@ test( "onlyVisible", function( assert ) {
9192
"onlyVisible: true: First button is hidden second button get corner class" );
9293
} );
9394

94-
test( "direction", function( assert ) {
95-
expect( 6 );
95+
QUnit.test( "direction", function( assert ) {
96+
assert.expect( 6 );
9697
var element = $( ".controlgroup" ).controlgroup(),
9798
buttons = element.children( ".ui-button" ).filter( ":visible" );
9899

0 commit comments

Comments
 (0)