aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-12-22 18:00:00 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-12-22 18:00:00 +0300
commit0b5e8dba05b59f218dfdf8d226076bf912f41ff2 (patch)
treedc3d1eb3a150253c6dbe9d2d8a3be8e4827c86c5 /test
parentfd5858f5423968aed8329f2cc0e5e590a7e05621 (diff)
downloadjquery-0b5e8dba05b59f218dfdf8d226076bf912f41ff2.tar.gz
jquery-0b5e8dba05b59f218dfdf8d226076bf912f41ff2.zip
Revert "Core: Remove deprecated context and selector properties"
This reverts commit e2ec5da2a7f1b3de1f9dc7e2c01f27cd23714e60.
Diffstat (limited to 'test')
-rw-r--r--test/unit/core.js52
-rw-r--r--test/unit/offset.js8
2 files changed, 51 insertions, 9 deletions
diff --git a/test/unit/core.js b/test/unit/core.js
index f2d6fbf51..ab5c11d34 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -62,6 +62,8 @@ QUnit.test( "jQuery()", function( assert ) {
equal( jQuery("").length, 0, "jQuery('') === jQuery([])" );
equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" );
+ equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" );
+
// can actually yield more than one, when iframes are included, the window is an array as well
assert.equal( jQuery( window ).length, 1, "Correct number of elements generated for jQuery(window)" );
@@ -153,12 +155,52 @@ QUnit.test( "jQuery(selector, context)", function( assert ) {
assert.deepEqual( jQuery( "div p", jQuery( "#qunit-fixture" ) ).get(), q( "sndp", "en", "sap" ), "Basic selector with jQuery object as context" );
} );
-QUnit.test( "globalEval", function( assert ) {
- assert.expect( 3 );
- Globals.register( "globalEvalTest" );
+test( "selector state", function() {
+ expect( 18 );
+
+ var test;
+
+ test = jQuery( undefined );
+ equal( test.selector, "", "Empty jQuery Selector" );
+ equal( test.context, undefined, "Empty jQuery Context" );
+
+ test = jQuery( document );
+ equal( test.selector, "", "Document Selector" );
+ equal( test.context, document, "Document Context" );
+
+ test = jQuery( document.body );
+ equal( test.selector, "", "Body Selector" );
+ equal( test.context, document.body, "Body Context" );
+
+ test = jQuery("#qunit-fixture");
+ equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
+ equal( test.context, document, "#qunit-fixture Context" );
- jQuery.globalEval( "globalEvalTest = 1;" );
- assert.equal( window.globalEvalTest, 1, "Test variable assignments are global" );
+ test = jQuery("#notfoundnono");
+ equal( test.selector, "#notfoundnono", "#notfoundnono Selector" );
+ equal( test.context, document, "#notfoundnono Context" );
+
+ test = jQuery( "#qunit-fixture", document );
+ equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
+ equal( test.context, document, "#qunit-fixture Context" );
+
+ test = jQuery( "#qunit-fixture", document.body );
+ equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
+ equal( test.context, document.body, "#qunit-fixture Context" );
+
+ // Test cloning
+ test = jQuery( test );
+ equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
+ equal( test.context, document.body, "#qunit-fixture Context" );
+
+ test = jQuery( document.body ).find("#qunit-fixture");
+ equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
+ equal( test.context, document.body, "#qunit-fixture find Context" );
+});
+
+QUnit.test( "globalEval", function( assert ) {
+ expect( 2 );
+ Globals.register("globalEvalTest");
jQuery.globalEval( "var globalEvalTest = 2;" );
assert.equal( window.globalEvalTest, 2, "Test variable declarations are global" );
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 48bde9239..768284f26 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -497,10 +497,10 @@ testIframe( "offset/body", "body", function( $, window, document, assert ) {
QUnit.test( "chaining", function( assert ) {
assert.expect( 3 );
var coords = { "top": 1, "left": 1 };
- assert.equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
- assert.equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
- assert.equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
-} );
+ equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
+ equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
+ equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
+});
QUnit.test( "offsetParent", function( assert ) {
assert.expect( 13 );