aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-01-03 20:39:15 -0500
committerDave Methvin <dave.methvin@gmail.com>2013-01-03 20:43:01 -0500
commit445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf (patch)
treec51fe7011a7811287d0b16a7547afe25154c2556 /test
parent0d540c3750bd5d702ec5cc425fd4eebd1089fa52 (diff)
downloadjquery-445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf.tar.gz
jquery-445dbd9d95e2df2f3cb454cb20ba3ae7a84e7eaf.zip
Revert data.js rewrite.
Reverts the following commits: commit f717226b3a44f918eec30b2d59ab257270189bc3 Author: Rick Waldron <waldron.rick@gmail.com> Date: Mon Dec 31 18:06:38 2012 -0500 Only splice from internal arrays when item actually exists. commit b9cdc4136b688963d1dc4befb169be02a0216ba9 Author: Rick Waldron <waldron.rick@gmail.com> Date: Mon Dec 31 16:20:35 2012 -0500 Updates to data.js re-write to pass events and manipulation commit d1de3000c6d50c298de14fb1ae3381d75c303723 Author: Rick Waldron <waldron.rick@gmail.com> Date: Mon Dec 31 15:09:45 2012 -0500 2.0: Rewrite data.js
Diffstat (limited to 'test')
-rw-r--r--test/data/testrunner.js115
-rw-r--r--test/unit/data.js41
2 files changed, 59 insertions, 97 deletions
diff --git a/test/data/testrunner.js b/test/data/testrunner.js
index 6c9665867..f7aca724a 100644
--- a/test/data/testrunner.js
+++ b/test/data/testrunner.js
@@ -200,51 +200,47 @@ var Globals = (function() {
*/
QUnit.expectJqData = function( elems, key ) {
var i, elem, expando;
+ QUnit.current_testEnvironment.checkJqData = true;
- if ( jQuery.cache ) {
- QUnit.current_testEnvironment.checkJqData = true;
+ if ( elems.jquery && elems.toArray ) {
+ elems = elems.toArray();
+ }
+ if ( !jQuery.isArray( elems ) ) {
+ elems = [ elems ];
+ }
- if ( elems.jquery && elems.toArray ) {
- elems = elems.toArray();
- }
- if ( !jQuery.isArray( elems ) ) {
- elems = [ elems ];
+ for ( i = 0; i < elems.length; i++ ) {
+ elem = elems[i];
+
+ // jQuery.data only stores data for nodes in jQuery.cache,
+ // for other data targets the data is stored in the object itself,
+ // in that case we can't test that target for memory leaks.
+ // But we don't have to since in that case the data will/must will
+ // be available as long as the object is not garbage collected by
+ // the js engine, and when it is, the data will be removed with it.
+ if ( !elem.nodeType ) {
+ // Fixes false positives for dataTests(window), dataTests({}).
+ continue;
}
- for ( i = 0; i < elems.length; i++ ) {
- elem = elems[i];
-
- // jQuery.data only stores data for nodes in jQuery.cache,
- // for other data targets the data is stored in the object itself,
- // in that case we can't test that target for memory leaks.
- // But we don't have to since in that case the data will/must will
- // be available as long as the object is not garbage collected by
- // the js engine, and when it is, the data will be removed with it.
- if ( !elem.nodeType ) {
- // Fixes false positives for dataTests(window), dataTests({}).
- continue;
- }
-
- expando = elem[ jQuery.expando ];
-
- if ( expando === undefined ) {
- // In this case the element exists fine, but
- // jQuery.data (or internal data) was never (in)directly
- // called.
- // Since this method was called it means some data was
- // expected to be found, but since there is nothing, fail early
- // (instead of in teardown).
- notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
+ expando = elem[ jQuery.expando ];
+
+ if ( expando === undefined ) {
+ // In this case the element exists fine, but
+ // jQuery.data (or internal data) was never (in)directly
+ // called.
+ // Since this method was called it means some data was
+ // expected to be found, but since there is nothing, fail early
+ // (instead of in teardown).
+ notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
+ } else {
+ if ( expectedDataKeys[expando] ) {
+ expectedDataKeys[expando].push( key );
} else {
- if ( expectedDataKeys[expando] ) {
- expectedDataKeys[expando].push( key );
- } else {
- expectedDataKeys[expando] = [ key ];
- }
+ expectedDataKeys[expando] = [ key ];
}
}
}
-
};
QUnit.config.urlConfig.push( {
id: "jqdata",
@@ -262,38 +258,33 @@ var Globals = (function() {
fragmentsLength = 0,
cacheLength = 0;
- if ( jQuery.cache ) {
- // Only look for jQuery data problems if this test actually
- // provided some information to compare against.
- if ( QUnit.urlParams.jqdata || this.checkJqData ) {
- for ( i in jQuery.cache ) {
- expectedKeys = expectedDataKeys[i];
- actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
- if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
- deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
- }
- delete jQuery.cache[i];
- delete expectedDataKeys[i];
- }
- // In case it was removed from cache before (or never there in the first place)
- for ( i in expectedDataKeys ) {
- deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
- delete expectedDataKeys[i];
+ // Only look for jQuery data problems if this test actually
+ // provided some information to compare against.
+ if ( QUnit.urlParams.jqdata || this.checkJqData ) {
+ for ( i in jQuery.cache ) {
+ expectedKeys = expectedDataKeys[i];
+ actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
+ if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
+ deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
}
+ delete jQuery.cache[i];
+ delete expectedDataKeys[i];
+ }
+ // In case it was removed from cache before (or never there in the first place)
+ for ( i in expectedDataKeys ) {
+ deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
+ delete expectedDataKeys[i];
}
-
- // Reset data register
- expectedDataKeys = {};
}
+ // Reset data register
+ expectedDataKeys = {};
// Allow QUnit.reset to clean up any attached elements before checking for leaks
QUnit.reset();
- if ( jQuery.cache ) {
- for ( i in jQuery.cache ) {
- ++cacheLength;
- }
+ for ( i in jQuery.cache ) {
+ ++cacheLength;
}
jQuery.fragments = {};
@@ -343,7 +334,7 @@ var Globals = (function() {
} else {
delete jQuery.ajaxSettings;
}
-
+
// Cleanup globals
Globals.cleanup();
diff --git a/test/unit/data.js b/test/unit/data.js
index c4eca1660..c09149b65 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -1,38 +1,11 @@
-module( "data", { teardown: moduleTeardown });
+module("data", { teardown: moduleTeardown });
-test( "expando", function() {
+test("expando", function(){
expect(1);
equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
});
-test( "jQuery.data & removeData, expected returns", function() {
- expect(2);
-
- equal(
- jQuery.data( document.body, "hello", "world" ), "world",
- "jjQuery.data( elem, key, value ) returns value"
- );
- equal(
- jQuery.removeData( document.body, "hello" ), undefined,
- "jjQuery.removeData( elem, key, value ) returns undefined"
- );
-
-});
-
-test( "jQuery._data & _removeData, expected returns", function() {
- expect(2);
-
- equal(
- jQuery._data( document.body, "hello", "world" ), "world",
- "jjQuery.data( elem, key, value ) returns value"
- );
- equal(
- jQuery._removeData( document.body, "hello" ), undefined,
- "jjQuery.removeData( elem, key, value ) returns undefined"
- );
-});
-
function dataTests (elem) {
var oldCacheLength, dataObj, internalDataObj, expected, actual;
@@ -126,7 +99,6 @@ test("jQuery.data(document)", 25, function() {
QUnit.expectJqData(document, "foo");
});
-/*
test("Expando cleanup", 4, function() {
var expected, actual,
div = document.createElement("div");
@@ -160,8 +132,7 @@ test("Expando cleanup", 4, function() {
// Clean up unattached element
jQuery(div).remove();
});
-*/
-/*
+
test("jQuery.acceptData", function() {
expect(7);
@@ -179,7 +150,7 @@ test("jQuery.acceptData", function() {
applet.setAttribute("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
ok( !jQuery.acceptData( applet ), "applet" );
});
-*/
+
test(".data()", function() {
expect(5);
@@ -494,8 +465,8 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
div.data("foo-bar", "d");
- equal( div.data("fooBar"), "d", "Verify updated data-* key (fooBar)" );
- equal( div.data("foo-bar"), "d", "Verify updated data-* key (foo-bar)" );
+ equal( div.data("fooBar"), "d", "Verify updated data-* key" );
+ equal( div.data("foo-bar"), "d", "Verify updated data-* key" );
div.remove();
});