1- define ( function ( ) {
2-
3- // Allow subprojects to test against their own fixtures
4- var qunitModule = QUnit . module ,
5- qunitTest = QUnit . test ,
6- // Store the old counts so that we only assert on tests that have actually leaked,
7- // instead of asserting every time a test has leaked sometime in the past
8- oldCacheLength = 0 ,
1+ ( function ( ) {
2+
3+ // Store the old counts so that we only assert on tests that have actually leaked,
4+ // instead of asserting every time a test has leaked sometime in the past
5+ var oldCacheLength = 0 ,
96 oldActive = 0 ,
107
118 expectedDataKeys = { } ,
12- reset ,
139 splice = [ ] . splice ,
1410 ajaxSettings = jQuery . ajaxSettings ;
1511
16-
1712/**
1813 * QUnit configuration
1914 */
@@ -45,7 +40,7 @@ QUnit.expectJqData = function( elems, key ) {
4540 }
4641
4742 for ( i = 0 ; i < elems . length ; i ++ ) {
48- elem = elems [ i ] ;
43+ elem = elems [ i ] ;
4944
5045 // jQuery.data only stores data for nodes in jQuery.cache,
5146 // for other data targets the data is stored in the object itself,
@@ -69,10 +64,10 @@ QUnit.expectJqData = function( elems, key ) {
6964 // (instead of in teardown).
7065 notStrictEqual ( expando , undefined , "Target for expectJqData must have an expando, for else there can be no data to expect." ) ;
7166 } else {
72- if ( expectedDataKeys [ expando ] ) {
73- expectedDataKeys [ expando ] . push ( key ) ;
67+ if ( expectedDataKeys [ expando ] ) {
68+ expectedDataKeys [ expando ] . push ( key ) ;
7469 } else {
75- expectedDataKeys [ expando ] = [ key ] ;
70+ expectedDataKeys [ expando ] = [ key ] ;
7671 }
7772 }
7873 }
@@ -90,26 +85,25 @@ QUnit.config.urlConfig.push({
9085 * teardown function on all modules' lifecycle object.
9186 */
9287window . moduleTeardown = function ( ) {
93- var i ,
94- expectedKeys , actualKeys ,
88+ var i , expectedKeys , actualKeys ,
9589 cacheLength = 0 ;
9690
9791 // Only look for jQuery data problems if this test actually
9892 // provided some information to compare against.
9993 if ( QUnit . urlParams . jqdata || this . checkJqData ) {
10094 for ( i in jQuery . cache ) {
101- expectedKeys = expectedDataKeys [ i ] ;
102- actualKeys = jQuery . cache [ i ] ? Object . keys ( jQuery . cache [ i ] ) : jQuery . cache [ i ] ;
95+ expectedKeys = expectedDataKeys [ i ] ;
96+ actualKeys = jQuery . cache [ i ] ? Object . keys ( jQuery . cache [ i ] ) : jQuery . cache [ i ] ;
10397 if ( ! QUnit . equiv ( expectedKeys , actualKeys ) ) {
10498 deepEqual ( actualKeys , expectedKeys , "Expected keys exist in jQuery.cache" ) ;
10599 }
106- delete jQuery . cache [ i ] ;
107- delete expectedDataKeys [ i ] ;
100+ delete jQuery . cache [ i ] ;
101+ delete expectedDataKeys [ i ] ;
108102 }
109103 // In case it was removed from cache before (or never there in the first place)
110104 for ( i in expectedDataKeys ) {
111- deepEqual ( expectedDataKeys [ i ] , undefined , "No unexpected keys were left in jQuery.cache (#" + i + ")" ) ;
112- delete expectedDataKeys [ i ] ;
105+ deepEqual ( expectedDataKeys [ i ] , undefined , "No unexpected keys were left in jQuery.cache (#" + i + ")" ) ;
106+ delete expectedDataKeys [ i ] ;
113107 }
114108 }
115109
@@ -143,18 +137,7 @@ window.moduleTeardown = function() {
143137 }
144138} ;
145139
146- QUnit . done ( function ( ) {
147- // Remove our own fixtures outside #qunit-fixture
148- supportjQuery ( "#qunit ~ *" ) . remove ( ) ;
149- } ) ;
150-
151- // jQuery-specific post-test cleanup
152- reset = function ( ) {
153-
154- // Ensure jQuery events and data on the fixture are properly removed
155- jQuery ( "#qunit-fixture" ) . empty ( ) ;
156- // ...even if the jQuery under test has a broken .empty()
157- supportjQuery ( "#qunit-fixture" ) . empty ( ) ;
140+ QUnit . testDone ( function ( ) {
158141
159142 // Reset internal jQuery state
160143 jQuery . event . global = { } ;
@@ -166,10 +149,7 @@ reset = function () {
166149
167150 // Cleanup globals
168151 Globals . cleanup ( ) ;
169- jQuery ( "#qunit-fixture" ) [ 0 ] . innerHTML = QUnit . config . fixture ;
170- } ;
171-
172- QUnit . testDone ( reset ) ;
152+ } ) ;
173153
174154// Register globals for cleanup and the cleanup code itself
175155window . Globals = ( function ( ) {
@@ -192,4 +172,4 @@ window.Globals = (function() {
192172 } ;
193173} ) ( ) ;
194174
195- } ) ;
175+ } ) ( ) ;
0 commit comments