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
|
||||
doc/*.html
|
||||
node_modules
|
||||
.idea
|
||||
|
||||
22
test/test.js
22
test/test.js
@@ -14830,7 +14830,7 @@
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
// sina
|
||||
|
||||
QUnit.module('lodash.merge');
|
||||
|
||||
(function() {
|
||||
@@ -14914,9 +14914,9 @@
|
||||
QUnit.test('should merge first source object properties to function', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const Foo = function () {};
|
||||
var object = { prop: {} },
|
||||
actual = _.merge({prop: Foo}, object);
|
||||
var fn = function() {},
|
||||
object = { 'prop': {} },
|
||||
actual = _.merge({ 'prop': fn }, object);
|
||||
|
||||
assert.deepEqual(actual, object);
|
||||
});
|
||||
@@ -14924,24 +14924,26 @@
|
||||
QUnit.test('should merge first and second source object properties to function', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const fn = function () {};
|
||||
var object = { prop: {} },
|
||||
actual = _.merge({prop: fn}, {prop: fn}, object);
|
||||
var fn = function() {},
|
||||
object = { 'prop': {} },
|
||||
actual = _.merge({ 'prop': fn }, { 'prop': fn }, object);
|
||||
|
||||
assert.deepEqual(actual, object);
|
||||
});
|
||||
|
||||
QUnit.test('should not merge onto function values of sources', function(assert) {
|
||||
assert.expect(2);
|
||||
assert.expect(3);
|
||||
|
||||
var source1 = { 'a': function() {} },
|
||||
source2 = { 'a': { 'b': 2 } },
|
||||
expected = { 'a': { 'b': 2 } },
|
||||
actual = _.merge({}, source1, source2);
|
||||
|
||||
assert.deepEqual(actual, { 'a': { 'b': 2 } });
|
||||
assert.deepEqual(actual, expected);
|
||||
assert.notOk('b' in source1.a);
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user