From 848301bf7024caae3ac53e06450096290279fbfb Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 22 Oct 2014 22:58:25 -0700 Subject: [PATCH] Add tests for clone methods and objects from other realms. --- test/test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test.js b/test/test.js index 4b4be42ba..f1f0f7f49 100644 --- a/test/test.js +++ b/test/test.js @@ -1814,6 +1814,23 @@ deepEqual(actual, ['a', 'b', 'c']); }); + test('`_.' + methodName + '` should produce an object from the same realm as `value`', 1, function() { + var objects = _.transform(_, function(result, value, key) { + if (_.startsWith(key, '_') && _.isObject(value) && !_.isElement(value) && !_.isFunction(value)) { + result.push(value); + } + }, []); + + var expected = _.times(objects.length, _.constant(true)); + + var actual = _.map(objects, function(object) { + var result = func(object); + return result !== object && result instanceof object.constructor; + }); + + deepEqual(actual, expected); + }); + test('`_.' + methodName + '` should return a unwrapped value when chaining', 2, function() { if (!isNpm) { var object = objects['objects'],