|
136 | 136 | strictEqual(_.extend(undefined, {a: 1}), undefined, 'extending undefined results in undefined'); |
137 | 137 | }); |
138 | 138 |
|
139 | | - test('extendOwn', function() { |
| 139 | + test('assign', function() { |
140 | 140 | var result; |
141 | | - equal(_.extendOwn({}, {a: 'b'}).a, 'b', 'can assign an object with the attributes of another'); |
142 | | - equal(_.extendOwn({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination'); |
143 | | - equal(_.extendOwn({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden"); |
144 | | - result = _.extendOwn({x: 'x'}, {a: 'a'}, {b: 'b'}); |
| 141 | + equal(_.assign({}, {a: 'b'}).a, 'b', 'can assign an object with the attributes of another'); |
| 142 | + equal(_.assign({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination'); |
| 143 | + equal(_.assign({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden"); |
| 144 | + result = _.assign({x: 'x'}, {a: 'a'}, {b: 'b'}); |
145 | 145 | deepEqual(result, {x: 'x', a: 'a', b: 'b'}, 'can assign from multiple source objects'); |
146 | | - result = _.extendOwn({x: 'x'}, {a: 'a', x: 2}, {a: 'b'}); |
| 146 | + result = _.assign({x: 'x'}, {a: 'a', x: 2}, {a: 'b'}); |
147 | 147 | deepEqual(result, {x: 2, a: 'b'}, 'assigning from multiple source objects last property trumps'); |
148 | | - deepEqual(_.extendOwn({}, {a: void 0, b: null}), {a: void 0, b: null}, 'assign copies undefined values'); |
| 148 | + deepEqual(_.assign({}, {a: void 0, b: null}), {a: void 0, b: null}, 'assign copies undefined values'); |
149 | 149 |
|
150 | 150 | var F = function() {}; |
151 | 151 | F.prototype = {a: 'b'}; |
152 | 152 | var subObj = new F(); |
153 | 153 | subObj.c = 'd'; |
154 | | - deepEqual(_.extendOwn({}, subObj), {c: 'd'}, 'assign copies own properties from source'); |
| 154 | + deepEqual(_.assign({}, subObj), {c: 'd'}, 'assign copies own properties from source'); |
155 | 155 |
|
156 | 156 | result = {}; |
157 | | - deepEqual(_.extendOwn(result, null, undefined, {a: 1}), {a: 1}, 'should not error on `null` or `undefined` sources'); |
| 157 | + deepEqual(_.assign(result, null, undefined, {a: 1}), {a: 1}, 'should not error on `null` or `undefined` sources'); |
158 | 158 |
|
159 | 159 | _.each(['a', 5, null, false], function(val) { |
160 | | - strictEqual(_.extendOwn(val, {a: 1}), val, 'assigning non-objects results in returning the non-object value'); |
| 160 | + strictEqual(_.assign(val, {a: 1}), val, 'assigning non-objects results in returning the non-object value'); |
161 | 161 | }); |
162 | 162 |
|
163 | | - strictEqual(_.extendOwn(undefined, {a: 1}), undefined, 'assigning undefined results in undefined'); |
| 163 | + strictEqual(_.assign(undefined, {a: 1}), undefined, 'assigning undefined results in undefined'); |
164 | 164 |
|
165 | | - result = _.extendOwn({a: 1, 0: 2, 1: '5', length: 6}, {0: 1, 1: 2, length: 2}); |
| 165 | + result = _.assign({a: 1, 0: 2, 1: '5', length: 6}, {0: 1, 1: 2, length: 2}); |
166 | 166 | deepEqual(result, {a: 1, 0: 1, 1: 2, length: 2}, 'assign should treat array-like objects like normal objects'); |
167 | 167 | }); |
168 | 168 |
|
|
0 commit comments