1
1
/*!
2
- * QUnit 1.17.1
2
+ * QUnit 1.17.2-pre
3
3
* http://qunitjs.com/
4
4
*
5
5
* Copyright jQuery Foundation and other contributors
6
6
* Released under the MIT license
7
7
* http://jquery.org/license
8
8
*
9
- * Date: 2015-01 -20T19:39Z
9
+ * Date: 2015-03 -20T19:32Z
10
10
*/
11
11
12
12
( function ( window ) {
@@ -189,14 +189,17 @@ config.modules.push( config.currentModule );
189
189
if ( urlParams . testId ) {
190
190
191
191
// Ensure that urlParams.testId is an array
192
- urlParams . testId = [ ] . concat ( urlParams . testId ) ;
192
+ urlParams . testId = decodeURIComponent ( urlParams . testId ) . split ( "," ) ;
193
193
for ( i = 0 ; i < urlParams . testId . length ; i ++ ) {
194
194
config . testId . push ( urlParams . testId [ i ] ) ;
195
195
}
196
196
}
197
197
198
198
// Figure out if we're running the tests from a server or not
199
199
QUnit . isLocal = location . protocol === "file:" ;
200
+
201
+ // Expose the current QUnit version
202
+ QUnit . version = "1.17.2-pre" ;
200
203
} ( ) ) ;
201
204
202
205
// Root QUnit object.
@@ -1123,7 +1126,7 @@ Test.prototype = {
1123
1126
1124
1127
valid : function ( ) {
1125
1128
var include ,
1126
- filter = config . filter ,
1129
+ filter = config . filter && config . filter . toLowerCase ( ) ,
1127
1130
module = QUnit . urlParams . module && QUnit . urlParams . module . toLowerCase ( ) ,
1128
1131
fullName = ( this . module . name + ": " + this . testName ) . toLowerCase ( ) ;
1129
1132
@@ -1146,7 +1149,7 @@ Test.prototype = {
1146
1149
1147
1150
include = filter . charAt ( 0 ) !== "!" ;
1148
1151
if ( ! include ) {
1149
- filter = filter . toLowerCase ( ) . slice ( 1 ) ;
1152
+ filter = filter . slice ( 1 ) ;
1150
1153
}
1151
1154
1152
1155
// If the filter matches, we need to honour include
@@ -1284,109 +1287,75 @@ QUnit.assert = Assert.prototype = {
1284
1287
return assert . test . push . apply ( assert . test , arguments ) ;
1285
1288
} ,
1286
1289
1287
- /**
1288
- * Asserts rough true-ish result.
1289
- * @name ok
1290
- * @function
1291
- * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
1292
- */
1293
1290
ok : function ( result , message ) {
1294
1291
message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " +
1295
1292
QUnit . dump . parse ( result ) ) ;
1296
1293
this . push ( ! ! result , result , true , message ) ;
1297
1294
} ,
1298
1295
1299
- /**
1300
- * Assert that the first two arguments are equal, with an optional message.
1301
- * Prints out both actual and expected values.
1302
- * @name equal
1303
- * @function
1304
- * @example equal( format( "{0} bytes.", 2), "2 bytes.", "replaces {0} with next argument" );
1305
- */
1296
+ notOk : function ( result , message ) {
1297
+ message = message || ( ! result ? "okay" : "failed, expected argument to be falsy, was: " +
1298
+ QUnit . dump . parse ( result ) ) ;
1299
+ this . push ( ! result , result , false , message ) ;
1300
+ } ,
1301
+
1306
1302
equal : function ( actual , expected , message ) {
1307
1303
/*jshint eqeqeq:false */
1308
1304
this . push ( expected == actual , actual , expected , message ) ;
1309
1305
} ,
1310
1306
1311
- /**
1312
- * @name notEqual
1313
- * @function
1314
- */
1315
1307
notEqual : function ( actual , expected , message ) {
1316
1308
/*jshint eqeqeq:false */
1317
1309
this . push ( expected != actual , actual , expected , message ) ;
1318
1310
} ,
1319
1311
1320
- /**
1321
- * @name propEqual
1322
- * @function
1323
- */
1324
1312
propEqual : function ( actual , expected , message ) {
1325
1313
actual = objectValues ( actual ) ;
1326
1314
expected = objectValues ( expected ) ;
1327
1315
this . push ( QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
1328
1316
} ,
1329
1317
1330
- /**
1331
- * @name notPropEqual
1332
- * @function
1333
- */
1334
1318
notPropEqual : function ( actual , expected , message ) {
1335
1319
actual = objectValues ( actual ) ;
1336
1320
expected = objectValues ( expected ) ;
1337
1321
this . push ( ! QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
1338
1322
} ,
1339
1323
1340
- /**
1341
- * @name deepEqual
1342
- * @function
1343
- */
1344
1324
deepEqual : function ( actual , expected , message ) {
1345
1325
this . push ( QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
1346
1326
} ,
1347
1327
1348
- /**
1349
- * @name notDeepEqual
1350
- * @function
1351
- */
1352
1328
notDeepEqual : function ( actual , expected , message ) {
1353
1329
this . push ( ! QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
1354
1330
} ,
1355
1331
1356
- /**
1357
- * @name strictEqual
1358
- * @function
1359
- */
1360
1332
strictEqual : function ( actual , expected , message ) {
1361
1333
this . push ( expected === actual , actual , expected , message ) ;
1362
1334
} ,
1363
1335
1364
- /**
1365
- * @name notStrictEqual
1366
- * @function
1367
- */
1368
1336
notStrictEqual : function ( actual , expected , message ) {
1369
1337
this . push ( expected !== actual , actual , expected , message ) ;
1370
1338
} ,
1371
1339
1372
1340
"throws" : function ( block , expected , message ) {
1373
1341
var actual , expectedType ,
1374
1342
expectedOutput = expected ,
1375
- ok = false ;
1343
+ ok = false ,
1344
+ currentTest = ( this instanceof Assert && this . test ) || QUnit . config . current ;
1376
1345
1377
1346
// 'expected' is optional unless doing string comparison
1378
1347
if ( message == null && typeof expected === "string" ) {
1379
1348
message = expected ;
1380
1349
expected = null ;
1381
1350
}
1382
1351
1383
- this . test . ignoreGlobalErrors = true ;
1352
+ currentTest . ignoreGlobalErrors = true ;
1384
1353
try {
1385
- block . call ( this . test . testEnvironment ) ;
1354
+ block . call ( currentTest . testEnvironment ) ;
1386
1355
} catch ( e ) {
1387
1356
actual = e ;
1388
1357
}
1389
- this . test . ignoreGlobalErrors = false ;
1358
+ currentTest . ignoreGlobalErrors = false ;
1390
1359
1391
1360
if ( actual ) {
1392
1361
expectedType = QUnit . objectType ( expected ) ;
@@ -1419,11 +1388,9 @@ QUnit.assert = Assert.prototype = {
1419
1388
expectedOutput = null ;
1420
1389
ok = true ;
1421
1390
}
1422
-
1423
- this . push ( ok , actual , expectedOutput , message ) ;
1424
- } else {
1425
- this . test . pushFailure ( message , null , "No exception was thrown." ) ;
1426
1391
}
1392
+
1393
+ currentTest . assert . push ( ok , actual , expectedOutput , message ) ;
1427
1394
}
1428
1395
} ;
1429
1396
@@ -1830,7 +1797,7 @@ QUnit.dump = (function() {
1830
1797
nonEnumerableProperties = [ "message" , "name" ] ;
1831
1798
for ( i in nonEnumerableProperties ) {
1832
1799
key = nonEnumerableProperties [ i ] ;
1833
- if ( key in map && ! ( key in keys ) ) {
1800
+ if ( key in map && inArray ( key , keys ) < 0 ) {
1834
1801
keys . push ( key ) ;
1835
1802
}
1836
1803
}
@@ -1949,6 +1916,7 @@ if ( typeof window !== "undefined" ) {
1949
1916
"start" ,
1950
1917
"stop" ,
1951
1918
"ok" ,
1919
+ "notOk" ,
1952
1920
"equal" ,
1953
1921
"notEqual" ,
1954
1922
"propEqual" ,
@@ -1981,6 +1949,13 @@ if ( typeof exports !== "undefined" && exports ) {
1981
1949
exports . QUnit = QUnit ;
1982
1950
}
1983
1951
1952
+ if ( typeof define === "function" && define . amd ) {
1953
+ define ( [ ] , function ( ) {
1954
+ return QUnit ;
1955
+ } ) ;
1956
+ QUnit . config . autostart = false ;
1957
+ }
1958
+
1984
1959
// Get a reference to the global object, like window in browsers
1985
1960
} ( ( function ( ) {
1986
1961
return this ;
@@ -2256,7 +2231,14 @@ function addEvent( elem, type, fn ) {
2256
2231
} else if ( elem . attachEvent ) {
2257
2232
2258
2233
// support: IE <9
2259
- elem . attachEvent ( "on" + type , fn ) ;
2234
+ elem . attachEvent ( "on" + type , function ( ) {
2235
+ var event = window . event ;
2236
+ if ( ! event . target ) {
2237
+ event . target = event . srcElement || document ;
2238
+ }
2239
+
2240
+ fn . call ( elem , event ) ;
2241
+ } ) ;
2260
2242
}
2261
2243
}
2262
2244
@@ -2427,12 +2409,16 @@ function setUrl( params ) {
2427
2409
}
2428
2410
2429
2411
function applyUrlParams ( ) {
2430
- var selectBox = id ( "qunit-modulefilter" ) ,
2431
- selection = decodeURIComponent ( selectBox . options [ selectBox . selectedIndex ] . value ) ,
2412
+ var selectedModule ,
2413
+ modulesList = id ( "qunit-modulefilter" ) ,
2432
2414
filter = id ( "qunit-filter-input" ) . value ;
2433
2415
2416
+ selectedModule = modulesList ?
2417
+ decodeURIComponent ( modulesList . options [ modulesList . selectedIndex ] . value ) :
2418
+ undefined ;
2419
+
2434
2420
window . location = setUrl ( {
2435
- module : ( selection === "" ) ? undefined : selection ,
2421
+ module : ( selectedModule === "" ) ? undefined : selectedModule ,
2436
2422
filter : ( filter === "" ) ? undefined : filter ,
2437
2423
2438
2424
// Remove testId filter
@@ -2588,9 +2574,14 @@ function storeFixture() {
2588
2574
2589
2575
function appendUserAgent ( ) {
2590
2576
var userAgent = id ( "qunit-userAgent" ) ;
2577
+
2591
2578
if ( userAgent ) {
2592
2579
userAgent . innerHTML = "" ;
2593
- userAgent . appendChild ( document . createTextNode ( navigator . userAgent ) ) ;
2580
+ userAgent . appendChild (
2581
+ document . createTextNode (
2582
+ "QUnit " + QUnit . version + "; " + navigator . userAgent
2583
+ )
2584
+ ) ;
2594
2585
}
2595
2586
}
2596
2587
@@ -2733,7 +2724,7 @@ function getNameHtml( name, module ) {
2733
2724
}
2734
2725
2735
2726
QUnit . testStart ( function ( details ) {
2736
- var running , testBlock ;
2727
+ var running , testBlock , bad ;
2737
2728
2738
2729
testBlock = id ( "qunit-test-output-" + details . testId ) ;
2739
2730
if ( testBlock ) {
@@ -2746,7 +2737,13 @@ QUnit.testStart(function( details ) {
2746
2737
2747
2738
running = id ( "qunit-testresult" ) ;
2748
2739
if ( running ) {
2749
- running . innerHTML = "Running: <br />" + getNameHtml ( details . name , details . module ) ;
2740
+ bad = QUnit . config . reorder && defined . sessionStorage &&
2741
+ + sessionStorage . getItem ( "qunit-test-" + details . module + "-" + details . name ) ;
2742
+
2743
+ running . innerHTML = ( bad ?
2744
+ "Rerunning previously failed test: <br />" :
2745
+ "Running: <br />" ) +
2746
+ getNameHtml ( details . name , details . module ) ;
2750
2747
}
2751
2748
2752
2749
} ) ;
@@ -2865,10 +2862,6 @@ QUnit.testDone(function( details ) {
2865
2862
2866
2863
if ( defined . document ) {
2867
2864
if ( document . readyState === "complete" ) {
2868
- if ( window . define && window . define . amd ) {
2869
- QUnit . config . autostart = false ;
2870
- }
2871
-
2872
2865
QUnit . load ( ) ;
2873
2866
} else {
2874
2867
addEvent ( window , "load" , QUnit . load ) ;
0 commit comments