Skip to content

Commit 611e364

Browse files
committed
Resizeable: Shift to use no globals
1 parent b7b53d2 commit 611e364

File tree

5 files changed

+306
-301
lines changed

5 files changed

+306
-301
lines changed

tests/unit/resizable/core.js

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
define( [
2+
"qunit",
23
"jquery",
34
"./helper",
45
"ui/widgets/resizable"
5-
], function( $, testHelper ) {
6+
], function( QUnit, $, testHelper ) {
67

7-
module( "resizable: core" );
8+
QUnit.module( "resizable: core" );
89

910
/*
10-
test("element types", function() {
11+
Test("element types", function() {
1112
var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form"
1213
+ ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr"
1314
+ ",acronym,code,samp,kbd,var,img,object,hr"
@@ -25,133 +26,133 @@ test("element types", function() {
2526
});
2627
*/
2728

28-
test( "n", function() {
29-
expect( 4 );
29+
QUnit.test( "n", function( assert ) {
30+
assert.expect( 4 );
3031

3132
var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { handles: "all" } );
3233

3334
testHelper.drag( handle, 0, -50 );
34-
equal( target.height(), 150, "compare height" );
35+
assert.equal( target.height(), 150, "compare height" );
3536

3637
testHelper.drag( handle, 0, 50 );
37-
equal( target.height(), 100, "compare height" );
38+
assert.equal( target.height(), 100, "compare height" );
3839

39-
equal( target[ 0 ].style.left, "", "left should not be modified" );
40-
equal( target[ 0 ].style.width, "", "width should not be modified" );
40+
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
41+
assert.equal( target[ 0 ].style.width, "", "width should not be modified" );
4142
} );
4243

43-
test( "s", function() {
44-
expect( 5 );
44+
QUnit.test( "s", function( assert ) {
45+
assert.expect( 5 );
4546

4647
var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { handles: "all" } );
4748

4849
testHelper.drag( handle, 0, 50 );
49-
equal( target.height(), 150, "compare height" );
50+
assert.equal( target.height(), 150, "compare height" );
5051

5152
testHelper.drag( handle, 0, -50 );
52-
equal( target.height(), 100, "compare height" );
53+
assert.equal( target.height(), 100, "compare height" );
5354

54-
equal( target[ 0 ].style.top, "", "top should not be modified" );
55-
equal( target[ 0 ].style.left, "", "left should not be modified" );
56-
equal( target[ 0 ].style.width, "", "width should not be modified" );
55+
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
56+
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
57+
assert.equal( target[ 0 ].style.width, "", "width should not be modified" );
5758
} );
5859

59-
test( "e", function() {
60-
expect( 5 );
60+
QUnit.test( "e", function( assert ) {
61+
assert.expect( 5 );
6162

6263
var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { handles: "all" } );
6364

6465
testHelper.drag( handle, 50 );
65-
equal( target.width(), 150, "compare width" );
66+
assert.equal( target.width(), 150, "compare width" );
6667

6768
testHelper.drag( handle, -50 );
68-
equal( target.width(), 100, "compare width" );
69+
assert.equal( target.width(), 100, "compare width" );
6970

70-
equal( target[ 0 ].style.height, "", "height should not be modified" );
71-
equal( target[ 0 ].style.top, "", "top should not be modified" );
72-
equal( target[ 0 ].style.left, "", "left should not be modified" );
71+
assert.equal( target[ 0 ].style.height, "", "height should not be modified" );
72+
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
73+
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
7374
} );
7475

75-
test( "w", function() {
76-
expect( 4 );
76+
QUnit.test( "w", function( assert ) {
77+
assert.expect( 4 );
7778

7879
var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { handles: "all" } );
7980

8081
testHelper.drag( handle, -50 );
81-
equal( target.width(), 150, "compare width" );
82+
assert.equal( target.width(), 150, "compare width" );
8283

8384
testHelper.drag( handle, 50 );
84-
equal( target.width(), 100, "compare width" );
85+
assert.equal( target.width(), 100, "compare width" );
8586

86-
equal( target[ 0 ].style.height, "", "height should not be modified" );
87-
equal( target[ 0 ].style.top, "", "top should not be modified" );
87+
assert.equal( target[ 0 ].style.height, "", "height should not be modified" );
88+
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
8889
} );
8990

90-
test( "ne", function() {
91-
expect( 5 );
91+
QUnit.test( "ne", function( assert ) {
92+
assert.expect( 5 );
9293

9394
var handle = ".ui-resizable-ne", target = $( "#resizable1" ).css( { overflow: "hidden" } ).resizable( { handles: "all" } );
9495

9596
testHelper.drag( handle, -50, -50 );
96-
equal( target.width(), 50, "compare width" );
97-
equal( target.height(), 150, "compare height" );
97+
assert.equal( target.width(), 50, "compare width" );
98+
assert.equal( target.height(), 150, "compare height" );
9899

99100
testHelper.drag( handle, 50, 50 );
100-
equal( target.width(), 100, "compare width" );
101-
equal( target.height(), 100, "compare height" );
101+
assert.equal( target.width(), 100, "compare width" );
102+
assert.equal( target.height(), 100, "compare height" );
102103

103-
equal( target[ 0 ].style.left, "", "left should not be modified" );
104+
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
104105
} );
105106

106-
test( "se", function() {
107-
expect( 6 );
107+
QUnit.test( "se", function( assert ) {
108+
assert.expect( 6 );
108109

109110
var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all" } );
110111

111112
testHelper.drag( handle, 50, 50 );
112-
equal( target.width(), 150, "compare width" );
113-
equal( target.height(), 150, "compare height" );
113+
assert.equal( target.width(), 150, "compare width" );
114+
assert.equal( target.height(), 150, "compare height" );
114115

115116
testHelper.drag( handle, -50, -50 );
116-
equal( target.width(), 100, "compare width" );
117-
equal( target.height(), 100, "compare height" );
117+
assert.equal( target.width(), 100, "compare width" );
118+
assert.equal( target.height(), 100, "compare height" );
118119

119-
equal( target[ 0 ].style.top, "", "top should not be modified" );
120-
equal( target[ 0 ].style.left, "", "left should not be modified" );
120+
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
121+
assert.equal( target[ 0 ].style.left, "", "left should not be modified" );
121122
} );
122123

123-
test( "sw", function() {
124-
expect( 5 );
124+
QUnit.test( "sw", function( assert ) {
125+
assert.expect( 5 );
125126

126127
var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all" } );
127128

128129
testHelper.drag( handle, -50, -50 );
129-
equal( target.width(), 150, "compare width" );
130-
equal( target.height(), 50, "compare height" );
130+
assert.equal( target.width(), 150, "compare width" );
131+
assert.equal( target.height(), 50, "compare height" );
131132

132133
testHelper.drag( handle, 50, 50 );
133-
equal( target.width(), 100, "compare width" );
134-
equal( target.height(), 100, "compare height" );
134+
assert.equal( target.width(), 100, "compare width" );
135+
assert.equal( target.height(), 100, "compare height" );
135136

136-
equal( target[ 0 ].style.top, "", "top should not be modified" );
137+
assert.equal( target[ 0 ].style.top, "", "top should not be modified" );
137138
} );
138139

139-
test( "nw", function() {
140-
expect( 4 );
140+
QUnit.test( "nw", function( assert ) {
141+
assert.expect( 4 );
141142

142143
var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all" } );
143144

144145
testHelper.drag( handle, -50, -50 );
145-
equal( target.width(), 150, "compare width" );
146-
equal( target.height(), 150, "compare height" );
146+
assert.equal( target.width(), 150, "compare width" );
147+
assert.equal( target.height(), 150, "compare height" );
147148

148149
testHelper.drag( handle, 50, 50 );
149-
equal( target.width(), 100, "compare width" );
150-
equal( target.height(), 100, "compare height" );
150+
assert.equal( target.width(), 100, "compare width" );
151+
assert.equal( target.height(), 100, "compare height" );
151152
} );
152153

153-
test( "handle with complex markup (#8756)", function() {
154-
expect( 2 );
154+
QUnit.test( "handle with complex markup (#8756)", function( assert ) {
155+
assert.expect( 2 );
155156

156157
$( "#resizable1" )
157158
.append(
@@ -164,14 +165,14 @@ test( "handle with complex markup (#8756)", function() {
164165
var handle = ".ui-resizable-w div", target = $( "#resizable1" ).resizable( { handles: "all" } );
165166

166167
testHelper.drag( handle, -50 );
167-
equal( target.width(), 150, "compare width" );
168+
assert.equal( target.width(), 150, "compare width" );
168169

169170
testHelper.drag( handle, 50 );
170-
equal( target.width(), 100, "compare width" );
171+
assert.equal( target.width(), 100, "compare width" );
171172
} );
172173

173-
test( "resizable accounts for scroll position correctly (#3815)", function() {
174-
expect( 4 );
174+
QUnit.test( "resizable accounts for scroll position correctly (#3815)", function( assert ) {
175+
assert.expect( 4 );
175176

176177
var position, top, left,
177178
container = $( "<div style='overflow:scroll;height:300px;width:300px;position:relative;'></div>" ).appendTo( "#qunit-fixture" ),
@@ -187,14 +188,14 @@ test( "resizable accounts for scroll position correctly (#3815)", function() {
187188
top = el.css( "top" );
188189

189190
testHelper.drag( handle, 50, 50 );
190-
deepEqual( el.position(), position, "position stays the same when resized" );
191-
equal( el.css( "left" ), left, "css('left') stays the same when resized" );
192-
equal( el.css( "top" ), top, "css('top') stays the same when resized" );
193-
equal( $( handle ).position().left, handlePosition + 50, "handle also moved" );
191+
assert.deepEqual( el.position(), position, "position stays the same when resized" );
192+
assert.equal( el.css( "left" ), left, "css('left') stays the same when resized" );
193+
assert.equal( el.css( "top" ), top, "css('top') stays the same when resized" );
194+
assert.equal( $( handle ).position().left, handlePosition + 50, "handle also moved" );
194195
} );
195196

196-
test( "resizable stores correct size when using helper and grid (#9547)", function() {
197-
expect( 2 );
197+
QUnit.test( "resizable stores correct size when using helper and grid (#9547)", function( assert ) {
198+
assert.expect( 2 );
198199

199200
var handle = ".ui-resizable-se",
200201
target = $( "#resizable1" ).resizable( {
@@ -204,12 +205,12 @@ test( "resizable stores correct size when using helper and grid (#9547)", functi
204205
} );
205206

206207
testHelper.drag( handle, 1, 1 );
207-
equal( target.width(), 100, "compare width" );
208-
equal( target.height(), 100, "compare height" );
208+
assert.equal( target.width(), 100, "compare width" );
209+
assert.equal( target.height(), 100, "compare height" );
209210
} );
210211

211-
test( "nested resizable", function() {
212-
expect( 4 );
212+
QUnit.test( "nested resizable", function( assert ) {
213+
assert.expect( 4 );
213214

214215
var outer = $( "<div id='outer' style='width:50px'></div>" ),
215216
inner = $( "<div id='inner' style='width:30px'></div>" ),
@@ -228,14 +229,14 @@ test( "nested resizable", function() {
228229
outerHandle = $( "#outer > .ui-resizable-e" );
229230

230231
testHelper.drag( innerHandle, 10 );
231-
equal( inner.width(), 40, "compare width of inner element" );
232+
assert.equal( inner.width(), 40, "compare width of inner element" );
232233
testHelper.drag( innerHandle, -10 );
233-
equal( inner.width(), 30, "compare width of inner element" );
234+
assert.equal( inner.width(), 30, "compare width of inner element" );
234235

235236
testHelper.drag( outerHandle, 10 );
236-
equal( outer.width(), 60, "compare width of outer element" );
237+
assert.equal( outer.width(), 60, "compare width of outer element" );
237238
testHelper.drag( outerHandle, -10 );
238-
equal( outer.width(), 50, "compare width of outer element" );
239+
assert.equal( outer.width(), 50, "compare width of outer element" );
239240

240241
inner.remove();
241242
outer.remove();

0 commit comments

Comments
 (0)