@@ -21,74 +21,6 @@ QUnit.config.testTimeout = 60e3; // 1 minute
2121// Enforce an "expect" argument or expect() call in all test bodies.
2222QUnit . config . requireExpects = true ;
2323
24- /**
25- * @param {jQuery|HTMLElement|Object|Array } elems Target (or array of targets) for jQuery.data.
26- * @param {string } key
27- */
28- QUnit . assert . expectJqData = function ( env , elems , key ) {
29- var i , elem , expando ;
30-
31- // As of jQuery 2.0, there will be no "cache"-data is
32- // stored and managed completely below the API surface
33- if ( jQuery . cache ) {
34- env . checkJqData = true ;
35-
36- if ( elems . jquery && elems . toArray ) {
37- elems = elems . toArray ( ) ;
38- }
39- if ( ! Array . isArray ( elems ) ) {
40- elems = [ elems ] ;
41- }
42-
43- for ( i = 0 ; i < elems . length ; i ++ ) {
44- elem = elems [ i ] ;
45-
46- // jQuery.data only stores data for nodes in jQuery.cache,
47- // for other data targets the data is stored in the object itself,
48- // in that case we can't test that target for memory leaks.
49- // But we don't have to since in that case the data will/must will
50- // be available as long as the object is not garbage collected by
51- // the js engine, and when it is, the data will be removed with it.
52- if ( ! elem . nodeType ) {
53-
54- // Fixes false positives for dataTests(window), dataTests({}).
55- continue ;
56- }
57-
58- expando = elem [ jQuery . expando ] ;
59-
60- if ( expando === undefined ) {
61-
62- // In this case the element exists fine, but
63- // jQuery.data (or internal data) was never (in)directly
64- // called.
65- // Since this method was called it means some data was
66- // expected to be found, but since there is nothing, fail early
67- // (instead of in teardown).
68- this . notStrictEqual (
69- expando ,
70- undefined ,
71- "Target for expectJqData must have an expando, " +
72- "for else there can be no data to expect."
73- ) ;
74- } else {
75- if ( expectedDataKeys [ expando ] ) {
76- expectedDataKeys [ expando ] . push ( key ) ;
77- } else {
78- expectedDataKeys [ expando ] = [ key ] ;
79- }
80- }
81- }
82- }
83-
84- } ;
85- QUnit . config . urlConfig . push ( {
86- id : "jqdata" ,
87- label : "Always check jQuery.data" ,
88- tooltip : "Trigger QUnit.expectJqData detection for all tests " +
89- "instead of just the ones that call it"
90- } ) ;
91-
9224/**
9325 * Ensures that tests have cleaned up properly after themselves. Should be passed as the
9426 * teardown function on all modules' lifecycle object.
@@ -97,30 +29,6 @@ window.moduleTeardown = function( assert ) {
9729 var i , expectedKeys , actualKeys ,
9830 cacheLength = 0 ;
9931
100- // Only look for jQuery data problems if this test actually
101- // provided some information to compare against.
102- if ( QUnit . urlParams . jqdata || this . checkJqData ) {
103- for ( i in jQuery . cache ) {
104- expectedKeys = expectedDataKeys [ i ] ;
105- actualKeys = jQuery . cache [ i ] ? Object . keys ( jQuery . cache [ i ] ) : jQuery . cache [ i ] ;
106- if ( ! QUnit . equiv ( expectedKeys , actualKeys ) ) {
107- assert . deepEqual ( actualKeys , expectedKeys , "Expected keys exist in jQuery.cache" ) ;
108- }
109- delete jQuery . cache [ i ] ;
110- delete expectedDataKeys [ i ] ;
111- }
112-
113- // In case it was removed from cache before (or never there in the first place)
114- for ( i in expectedDataKeys ) {
115- assert . deepEqual (
116- expectedDataKeys [ i ] ,
117- undefined ,
118- "No unexpected keys were left in jQuery.cache (#" + i + ")"
119- ) ;
120- delete expectedDataKeys [ i ] ;
121- }
122- }
123-
12432 // Reset data register
12533 expectedDataKeys = { } ;
12634
0 commit comments