Selaa lähdekoodia

make utils.extend() returns the extended object

Pierre Bertet 12 vuotta sitten
vanhempi
commit
03800902ca
2 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 1 0
      src/utils.js
  2. 6 0
      test/unit/specs/utils.js

+ 1 - 0
src/utils.js

@@ -89,6 +89,7 @@ var utils = module.exports = {
             if (protective && obj[key]) continue
             obj[key] = ext[key]
         }
+        return obj
     },
 
     /**

+ 6 - 0
test/unit/specs/utils.js

@@ -137,6 +137,12 @@ describe('UNIT: Utils', function () {
             assert.strictEqual(a.b, b.b)
         })
 
+        it('should always return the extended object', function () {
+            var a = {a: 1}, b = {a: {}, b: 2}
+            assert.strictEqual(a, utils.extend(a, b))
+            assert.strictEqual(a, utils.extend(a, undefined))
+        })
+
     })
 
     describe('unique', function () {