mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Cleanup _.merge tests for function properties.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,4 +2,3 @@
|
|||||||
*.log
|
*.log
|
||||||
doc/*.html
|
doc/*.html
|
||||||
node_modules
|
node_modules
|
||||||
.idea
|
|
||||||
|
|||||||
22
test/test.js
22
test/test.js
@@ -14830,7 +14830,7 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
// sina
|
|
||||||
QUnit.module('lodash.merge');
|
QUnit.module('lodash.merge');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
@@ -14914,9 +14914,9 @@
|
|||||||
QUnit.test('should merge first source object properties to function', function(assert) {
|
QUnit.test('should merge first source object properties to function', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
const Foo = function () {};
|
var fn = function() {},
|
||||||
var object = { prop: {} },
|
object = { 'prop': {} },
|
||||||
actual = _.merge({prop: Foo}, object);
|
actual = _.merge({ 'prop': fn }, object);
|
||||||
|
|
||||||
assert.deepEqual(actual, object);
|
assert.deepEqual(actual, object);
|
||||||
});
|
});
|
||||||
@@ -14924,24 +14924,26 @@
|
|||||||
QUnit.test('should merge first and second source object properties to function', function(assert) {
|
QUnit.test('should merge first and second source object properties to function', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
const fn = function () {};
|
var fn = function() {},
|
||||||
var object = { prop: {} },
|
object = { 'prop': {} },
|
||||||
actual = _.merge({prop: fn}, {prop: fn}, object);
|
actual = _.merge({ 'prop': fn }, { 'prop': fn }, object);
|
||||||
|
|
||||||
assert.deepEqual(actual, object);
|
assert.deepEqual(actual, object);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should not merge onto function values of sources', function(assert) {
|
QUnit.test('should not merge onto function values of sources', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(3);
|
||||||
|
|
||||||
var source1 = { 'a': function() {} },
|
var source1 = { 'a': function() {} },
|
||||||
source2 = { 'a': { 'b': 2 } },
|
source2 = { 'a': { 'b': 2 } },
|
||||||
|
expected = { 'a': { 'b': 2 } },
|
||||||
actual = _.merge({}, source1, source2);
|
actual = _.merge({}, source1, source2);
|
||||||
|
|
||||||
assert.deepEqual(actual, { 'a': { 'b': 2 } });
|
assert.deepEqual(actual, expected);
|
||||||
|
assert.notOk('b' in source1.a);
|
||||||
|
|
||||||
actual = _.merge(source1, source2);
|
actual = _.merge(source1, source2);
|
||||||
assert.strictEqual(actual.a.b, 2);
|
assert.deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should merge onto non-plain `object` values', function(assert) {
|
QUnit.test('should merge onto non-plain `object` values', function(assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user