Skip to content

Commit 15ea001

Browse files
committed
Tests: QUnit 2.0 compatibility
1 parent e967c3b commit 15ea001

File tree

12 files changed

+115
-114
lines changed

12 files changed

+115
-114
lines changed

test/ajax.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module( "ajax" );
1+
QUnit.module( "ajax" );
22

3-
test( "jQuery.ajax() deprecations on jqXHR", function( assert ) {
3+
QUnit.test( "jQuery.ajax() deprecations on jqXHR", function( assert ) {
44
assert.expect( 3 );
55

66
var done = assert.async();
77

8-
expectWarning( ".success(), .error(), .compete() calls", 3, function() {
8+
expectWarning( assert, ".success(), .error(), .compete() calls", 3, function() {
99

1010
jQuery.ajax( "/not-found.404" )
1111
.success( jQuery.noop )
@@ -16,7 +16,8 @@ test( "jQuery.ajax() deprecations on jqXHR", function( assert ) {
1616
} )
1717
.complete( function() {
1818
assert.ok( true, "ajax complete" );
19-
done();
19+
// Wait for expectWarning to complete
20+
setTimeout(done, 1);
2021
} );
2122
} );
2223

test/attributes.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ QUnit.module( "attributes" );
44
QUnit.test( ".removeAttr( boolean attribute )", function( assert ) {
55
assert.expect( 8 );
66

7-
expectNoWarning( "non-boolean attr", function() {
7+
expectNoWarning( assert, "non-boolean attr", function() {
88
var $div = jQuery( "<div />" )
99
.attr( "quack", "duck" )
1010
.removeAttr( "quack" );
@@ -13,7 +13,7 @@ QUnit.test( ".removeAttr( boolean attribute )", function( assert ) {
1313
assert.equal( $div.prop( "quack" ), undefined, "property was not set" );
1414
} );
1515

16-
expectWarning( "boolean attr", function() {
16+
expectWarning( assert, "boolean attr", function() {
1717
var $inp = jQuery( "<input type=checkbox/>" )
1818
.attr( "checked", "checked" )
1919
.prop( "checked", true )
@@ -24,14 +24,14 @@ QUnit.test( ".removeAttr( boolean attribute )", function( assert ) {
2424
} );
2525

2626
// One warning per attribute name
27-
expectWarning( "multiple boolean attr", 2, function() {
27+
expectWarning( assert, "multiple boolean attr", 2, function() {
2828
jQuery( "<input type=checkbox/>" )
2929
.attr( "checked", "checked" )
3030
.attr( "readonly", "readonly" )
3131
.removeAttr( "checked readonly" );
3232
} );
3333

34-
expectWarning( "mixed attr, one boolean", function() {
34+
expectWarning( assert, "mixed attr, one boolean", function() {
3535
jQuery( "<input />" )
3636
.attr( "type", "text" )
3737
.attr( "size", "15" )
@@ -47,20 +47,20 @@ QUnit.test( ".toggleClass( boolean )", function( assert ) {
4747

4848
var e = jQuery( "<div />" ).appendTo( "#qunit-fixture" );
4949

50-
expectWarning( "toggling initially empty class", function() {
50+
expectWarning( assert, "toggling initially empty class", function() {
5151
e.toggleClass( true );
5252
assert.equal( e[ 0 ].className, "", "Assert class is empty (data was empty)" );
5353
} );
5454

55-
expectNoWarning( ".toggleClass( string ) not full className", function() {
55+
expectNoWarning( assert, ".toggleClass( string ) not full className", function() {
5656
e.attr( "class", "" );
5757
e.toggleClass( "classy" );
5858
assert.equal( e.attr( "class" ), "classy", "class was toggle-set" );
5959
e.toggleClass( "classy", false );
6060
assert.equal( e.attr( "class" ), "", "class was toggle-removed" );
6161
} );
6262

63-
expectWarning( ".toggleClass() save and clear", 1, function() {
63+
expectWarning( assert, ".toggleClass() save and clear", 1, function() {
6464
e.addClass( "testD testE" );
6565
assert.ok( e.is( ".testD.testE" ), "Assert class present" );
6666
e.toggleClass();
@@ -69,12 +69,12 @@ QUnit.test( ".toggleClass( boolean )", function( assert ) {
6969
// N.B.: Store should have "testD testE" now, next test will assert that
7070
} );
7171

72-
expectWarning( ".toggleClass() restore", 1, function() {
72+
expectWarning( assert, ".toggleClass() restore", 1, function() {
7373
e.toggleClass();
7474
assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" );
7575
} );
7676

77-
expectWarning( ".toggleClass( boolean )", 1, function() {
77+
expectWarning( assert, ".toggleClass( boolean )", 1, function() {
7878
e.toggleClass( false );
7979
assert.ok( !e.is( ".testD.testE" ), "Assert class not present" );
8080
e.toggleClass( true );

test/core.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11

2-
module( "core" );
2+
QUnit.module( "core" );
33

4-
test( "jQuery.migrateVersion", function( assert ) {
4+
QUnit.test( "jQuery.migrateVersion", function( assert ) {
55
assert.expect( 1 );
66

77
assert.ok( /^\d+\.\d+\.[\w\-]+/.test( jQuery.migrateVersion ), "Version property" );
88
} );
99

10-
test( "jQuery(html, props)", function() {
11-
expect( 3 );
10+
QUnit.test( "jQuery(html, props)", function( assert ) {
11+
assert.expect( 3 );
1212

1313
var $el = jQuery( "<input/>", { name: "name", val: "value", size: 42 } );
1414

15-
equal( $el.attr( "name" ), "name", "Name attribute" );
16-
equal( $el.attr( "size" ),
15+
assert.equal( $el.attr( "name" ), "name", "Name attribute" );
16+
assert.equal( $el.attr( "size" ),
1717
jQuery.isEmptyObject( jQuery.attrFn ) ? undefined : "42", "Size attribute" );
18-
equal( $el.val(), "value", "Call setter method" );
18+
assert.equal( $el.val(), "value", "Call setter method" );
1919
} );
2020

21-
test( "jQuery( '#' )", function() {
22-
expect( 2 );
21+
QUnit.test( "jQuery( '#' )", function( assert ) {
22+
assert.expect( 2 );
2323

24-
expectWarning( "Selector, through the jQuery constructor, nothing but hash", function() {
24+
expectWarning( assert, "Selector, through the jQuery constructor, nothing but hash", function() {
2525
var set = jQuery( "#" );
26-
equal( set.length, 0, "empty set" );
26+
assert.equal( set.length, 0, "empty set" );
2727
} );
2828
} );
2929

3030
QUnit.test( "Attribute selectors with unquoted hashes", function( assert ) {
31-
expect( 31 );
31+
assert.expect( 31 );
3232

3333
var markup = jQuery(
3434
"<div>" +
@@ -73,28 +73,28 @@ QUnit.test( "Attribute selectors with unquoted hashes", function( assert ) {
7373
"a[href=space#junk]:eq(1)"
7474
];
7575

76-
expectNoWarning( "Perfectly cromulent selectors are unchanged", function() {
76+
expectNoWarning( assert, "Perfectly cromulent selectors are unchanged", function() {
7777
okays.forEach( function( okay ) {
7878
assert.equal( jQuery( okay, markup ).length, 1, okay );
7979
assert.equal( markup.find( okay ).length, 1, okay );
8080
} );
8181
} );
8282

83-
expectWarning( "Values with unquoted hashes are quoted", fixables.length, function() {
83+
expectWarning( assert, "Values with unquoted hashes are quoted", fixables.length, function() {
8484
fixables.forEach( function( fixable ) {
8585
assert.equal( jQuery( fixable, markup ).length, 1, fixable );
8686
assert.equal( markup.find( fixable ).length, 1, fixable );
8787
} );
8888
} );
8989

90-
expectWarning( "False positives", positives.length, function() {
90+
expectWarning( assert, "False positives", positives.length, function() {
9191
positives.forEach( function( positive ) {
9292
assert.equal( jQuery( positive, markup ).length, 1, positive );
9393
assert.equal( markup.find( positive ).length, 1, positive );
9494
} );
9595
} );
9696

97-
expectWarning( "Unfixable cases", failures.length, function() {
97+
expectWarning( assert, "Unfixable cases", failures.length, function() {
9898
failures.forEach( function( failure ) {
9999
try {
100100
jQuery( failure, markup );
@@ -108,7 +108,7 @@ QUnit.test( "Attribute selectors with unquoted hashes", function( assert ) {
108108
} );
109109

110110
// Ensure we don't process jQuery( x ) when x is a function
111-
expectNoWarning( "ready function with attribute selector", function() {
111+
expectNoWarning( assert, "ready function with attribute selector", function() {
112112
try {
113113
jQuery( function() {
114114
if ( jQuery.thisIsNeverTrue ) {
@@ -119,7 +119,7 @@ QUnit.test( "Attribute selectors with unquoted hashes", function( assert ) {
119119
} );
120120
} );
121121

122-
test( "XSS injection (leading hash)", function( assert ) {
122+
QUnit.test( "XSS injection (leading hash)", function( assert ) {
123123
assert.expect( 1 );
124124

125125
var threw = false;
@@ -133,7 +133,7 @@ test( "XSS injection (leading hash)", function( assert ) {
133133
assert.equal( threw, true, "Throw on leading-hash HTML (treated as selector)" );
134134
} );
135135

136-
test( "XSS injection (XSS via script tag)", function( assert ) {
136+
QUnit.test( "XSS injection (XSS via script tag)", function( assert ) {
137137
assert.expect( 2 );
138138

139139
var threw = false;
@@ -147,7 +147,7 @@ test( "XSS injection (XSS via script tag)", function( assert ) {
147147
assert.equal( window.XSS, false, "XSS" );
148148
} );
149149

150-
test( "XSS injection (XSS with hash and leading space)", function( assert ) {
150+
QUnit.test( "XSS injection (XSS with hash and leading space)", function( assert ) {
151151
assert.expect( 2 );
152152

153153
var threw = false;
@@ -161,7 +161,7 @@ test( "XSS injection (XSS with hash and leading space)", function( assert ) {
161161
assert.equal( window.XSS, false, "XSS" );
162162
} );
163163

164-
test( "XSS injection (XSS via onerror inline handler)", function( assert ) {
164+
QUnit.test( "XSS injection (XSS via onerror inline handler)", function( assert ) {
165165
assert.expect( 2 );
166166

167167
var start,
@@ -182,25 +182,25 @@ test( "XSS injection (XSS via onerror inline handler)", function( assert ) {
182182
}, 1000 );
183183
} );
184184

185-
test( "jQuery( '<element>' ) usable on detached elements (#128)", function( assert ) {
185+
QUnit.test( "jQuery( '<element>' ) usable on detached elements (#128)", function( assert ) {
186186
assert.expect( 1 );
187187

188188
jQuery( "<a>" ).outerWidth();
189189
assert.ok( true, "No crash when operating on detached elements with window" );
190190
} );
191191

192-
test( ".size", function( assert ) {
192+
QUnit.test( ".size", function( assert ) {
193193
assert.expect( 1 );
194194

195-
expectWarning( "size", function() {
195+
expectWarning( assert, "size", function() {
196196
jQuery( "<div />" ).size();
197197
} );
198198
} );
199199

200-
test( "jQuery.parseJSON", function( assert ) {
200+
QUnit.test( "jQuery.parseJSON", function( assert ) {
201201
assert.expect( 2 );
202202

203-
expectWarning( "jQuery.parseJSON", function() {
203+
expectWarning( assert, "jQuery.parseJSON", function() {
204204
assert.deepEqual(
205205
jQuery.parseJSON( "{\"a\":1}" ),
206206
{ a: 1 },
@@ -209,7 +209,7 @@ test( "jQuery.parseJSON", function( assert ) {
209209
} );
210210
} );
211211

212-
test( "jQuery.isNumeric", function( assert ) {
212+
QUnit.test( "jQuery.isNumeric", function( assert ) {
213213
assert.expect( 8 );
214214

215215
var ToString = function( value ) {
@@ -218,12 +218,12 @@ test( "jQuery.isNumeric", function( assert ) {
218218
};
219219
};
220220

221-
expectWarning( "changed cases", function() {
221+
expectWarning( assert, "changed cases", function() {
222222
assert.equal( jQuery.isNumeric( new ToString( "42" ) ), true,
223223
"Custom .toString returning number" );
224224
} );
225225

226-
expectNoWarning( "unchanged cases", function() {
226+
expectNoWarning( assert, "unchanged cases", function() {
227227
assert.equal( jQuery.isNumeric( 42 ), true, "number" );
228228
assert.equal( jQuery.isNumeric( "42" ), true, "number string" );
229229
assert.equal( jQuery.isNumeric( "devo" ), false, "non-numeric string" );
@@ -233,10 +233,10 @@ test( "jQuery.isNumeric", function( assert ) {
233233
} );
234234
} );
235235

236-
test( "jQuery.unique", function( assert ) {
236+
QUnit.test( "jQuery.unique", function( assert ) {
237237
assert.expect( 2 );
238238

239-
expectWarning( "jQuery.unique", function() {
239+
expectWarning( assert, "jQuery.unique", function() {
240240
var body = jQuery( "body" )[ 0 ],
241241
head = jQuery( "head" )[ 0 ];
242242
assert.deepEqual(
@@ -246,22 +246,22 @@ test( "jQuery.unique", function( assert ) {
246246
} );
247247
} );
248248

249-
test( "jQuery.expr.pseudos aliases", function( assert ) {
249+
QUnit.test( "jQuery.expr.pseudos aliases", function( assert ) {
250250
assert.expect( 7 );
251251

252-
expectWarning( "jQuery.expr.filters", function() {
252+
expectWarning( assert, "jQuery.expr.filters", function() {
253253
jQuery.expr.filters.mazda = function( elem ) {
254254
return elem.style.zoom === "3";
255255
};
256256
} );
257257

258-
expectWarning( "jQuery.expr[':']", function() {
258+
expectWarning( assert, "jQuery.expr[':']", function() {
259259
jQuery.expr[ ":" ].marginal = function( elem ) {
260260
return parseInt( elem.style.marginLeftWidth ) > 20;
261261
};
262262
} );
263263

264-
expectNoWarning( "jQuery.expr.pseudos", function() {
264+
expectNoWarning( assert, "jQuery.expr.pseudos", function() {
265265
var fixture = jQuery( "#qunit-fixture" ).prepend( "<p>hello</p>" );
266266

267267
assert.ok( jQuery.expr.pseudos.mazda, "filters assigned" );
@@ -278,7 +278,7 @@ test( "jQuery.expr.pseudos aliases", function( assert ) {
278278
QUnit.test( "jQuery.holdReady (warn only)", function( assert ) {
279279
assert.expect( 1 );
280280

281-
expectWarning( "jQuery.holdReady", 1, function() {
281+
expectWarning( assert, "jQuery.holdReady", 1, function() {
282282
jQuery.holdReady( true );
283283
jQuery.holdReady( false );
284284
} );

test/css.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
module( "css" );
2+
QUnit.module( "css" );
33

4-
test( "jQuery.swap()", function( assert ) {
4+
QUnit.test( "jQuery.swap()", function( assert ) {
55
assert.expect( 6 );
66

77
var div = document.createElement( "div" );
88
div.style.borderWidth = "4px";
99

10-
expectWarning( "External swap() call", function() {
10+
expectWarning( assert, "External swap() call", function() {
1111
jQuery.swap( div, { borderRightWidth: "5px" }, function( arg ) {
1212

1313
assert.equal( this.style.borderRightWidth, "5px", "style was changed" );
@@ -17,7 +17,7 @@ test( "jQuery.swap()", function( assert ) {
1717
} );
1818
assert.equal( div.style.borderRightWidth, "4px", "style was restored" );
1919

20-
expectNoWarning( "Internal swap() call", function() {
20+
expectNoWarning( assert, "Internal swap() call", function() {
2121
var $fp = jQuery( "#firstp" ).width( "10em" ),
2222
width = $fp.width();
2323

0 commit comments

Comments
 (0)