]> source.dussan.org Git - jquery.git/commitdiff
Tests: Add .extend test for defined accessor properties
authorOleg Gaidarenko <markelog@gmail.com>
Mon, 12 Oct 2015 14:28:48 +0000 (17:28 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Mon, 12 Oct 2015 14:28:48 +0000 (17:28 +0300)
Ref 9748e436ad80d6a2e1661ba4cf8d7391ed87c3ad
Closes gh-2615

test/unit/core.js

index e466dad8d22149aaebe2cf752e0490708e5f646f..f8fb1c7cdbdc62721dab16ae27572e5a0a291366 100644 (file)
@@ -1085,6 +1085,36 @@ QUnit.test( "jQuery.extend(Object, Object)", function( assert ) {
        assert.deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
 } );
 
+QUnit.test( "jQuery.extend(Object, Object {created with \"defineProperties\"})", function( assert ) {
+
+       // Support: IE8 only
+       if ( !( "defineProperties" in Object ) ) {
+               assert.expect( 0 );
+               return;
+       }
+
+       assert.expect( 2 );
+
+       var definedObj = Object.defineProperties({}, {
+        "enumerableProp": {
+          get: function () {
+            return true;
+          },
+          enumerable: true
+        },
+        "nonenumerableProp": {
+          get: function () {
+            return true;
+          }
+        }
+      }),
+      accessorObj = {};
+
+       jQuery.extend( accessorObj, definedObj );
+       assert.equal( accessorObj.enumerableProp, true, "Verify that getters are transferred" );
+       assert.equal( accessorObj.nonenumerableProp, undefined, "Verify that non-enumerable getters are ignored" );
+} );
+
 QUnit.test( "jQuery.each(Object,Function)", function( assert ) {
        assert.expect( 23 );