@@ -62,6 +62,8 @@ QUnit.test( "jQuery()", function( assert ) {
6262 equal ( jQuery ( "" ) . length , 0 , "jQuery('') === jQuery([])" ) ;
6363 equal ( jQuery ( "#" ) . length , 0 , "jQuery('#') === jQuery([])" ) ;
6464
65+ equal ( jQuery ( obj ) . selector , "div" , "jQuery(jQueryObj) == jQueryObj" ) ;
66+
6567 // can actually yield more than one, when iframes are included, the window is an array as well
6668 assert . equal ( jQuery ( window ) . length , 1 , "Correct number of elements generated for jQuery(window)" ) ;
6769
@@ -153,12 +155,52 @@ QUnit.test( "jQuery(selector, context)", function( assert ) {
153155 assert . deepEqual ( jQuery ( "div p" , jQuery ( "#qunit-fixture" ) ) . get ( ) , q ( "sndp" , "en" , "sap" ) , "Basic selector with jQuery object as context" ) ;
154156} ) ;
155157
156- QUnit . test ( "globalEval" , function ( assert ) {
157- assert . expect ( 3 ) ;
158- Globals . register ( "globalEvalTest" ) ;
158+ test ( "selector state" , function ( ) {
159+ expect ( 18 ) ;
160+
161+ var test ;
162+
163+ test = jQuery ( undefined ) ;
164+ equal ( test . selector , "" , "Empty jQuery Selector" ) ;
165+ equal ( test . context , undefined , "Empty jQuery Context" ) ;
166+
167+ test = jQuery ( document ) ;
168+ equal ( test . selector , "" , "Document Selector" ) ;
169+ equal ( test . context , document , "Document Context" ) ;
170+
171+ test = jQuery ( document . body ) ;
172+ equal ( test . selector , "" , "Body Selector" ) ;
173+ equal ( test . context , document . body , "Body Context" ) ;
174+
175+ test = jQuery ( "#qunit-fixture" ) ;
176+ equal ( test . selector , "#qunit-fixture" , "#qunit-fixture Selector" ) ;
177+ equal ( test . context , document , "#qunit-fixture Context" ) ;
159178
160- jQuery . globalEval ( "globalEvalTest = 1;" ) ;
161- assert . equal ( window . globalEvalTest , 1 , "Test variable assignments are global" ) ;
179+ test = jQuery ( "#notfoundnono" ) ;
180+ equal ( test . selector , "#notfoundnono" , "#notfoundnono Selector" ) ;
181+ equal ( test . context , document , "#notfoundnono Context" ) ;
182+
183+ test = jQuery ( "#qunit-fixture" , document ) ;
184+ equal ( test . selector , "#qunit-fixture" , "#qunit-fixture Selector" ) ;
185+ equal ( test . context , document , "#qunit-fixture Context" ) ;
186+
187+ test = jQuery ( "#qunit-fixture" , document . body ) ;
188+ equal ( test . selector , "#qunit-fixture" , "#qunit-fixture Selector" ) ;
189+ equal ( test . context , document . body , "#qunit-fixture Context" ) ;
190+
191+ // Test cloning
192+ test = jQuery ( test ) ;
193+ equal ( test . selector , "#qunit-fixture" , "#qunit-fixture Selector" ) ;
194+ equal ( test . context , document . body , "#qunit-fixture Context" ) ;
195+
196+ test = jQuery ( document . body ) . find ( "#qunit-fixture" ) ;
197+ equal ( test . selector , "#qunit-fixture" , "#qunit-fixture find Selector" ) ;
198+ equal ( test . context , document . body , "#qunit-fixture find Context" ) ;
199+ } ) ;
200+
201+ QUnit . test ( "globalEval" , function ( assert ) {
202+ expect ( 2 ) ;
203+ Globals . register ( "globalEvalTest" ) ;
162204
163205 jQuery . globalEval ( "var globalEvalTest = 2;" ) ;
164206 assert . equal ( window . globalEvalTest , 2 , "Test variable declarations are global" ) ;
0 commit comments