diff --git a/build.js b/build.js index e8b6b23f8..1630c7e80 100755 --- a/build.js +++ b/build.js @@ -1708,7 +1708,7 @@ exposeZipObject = methods.indexOf('zipObject') > -1; methods = _.without.apply(_, [plusMethods].concat(minusMethods)); - useUnderscoreClone = methods.indexOf('clone') < 0; + useUnderscoreClone = methods.indexOf('clone') < 0 && methods.indexOf('cloneDeep') < 0; } // update dependencies if (isLegacy) { diff --git a/test/test-build.js b/test/test-build.js index 380cf71e0..8db52ca52 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -994,21 +994,34 @@ }); }); - asyncTest('`lodash underscore plus=clone`', function() { - var start = _.after(2, _.once(QUnit.start)); + var commands = [ + 'plus=clone', + 'plus=cloneDeep' + ]; - build(['-s', 'underscore', 'plus=clone'], function(data) { - var array = [{ 'value': 1 }], - basename = path.basename(data.outputPath, '.js'), - context = createContext(); + commands.forEach(function(command, index) { + asyncTest('`lodash ' + command +'`', function() { + var start = _.after(2, _.once(QUnit.start)); - vm.runInContext(data.source, context); - var lodash = context._, - clone = lodash.clone(array, true); + build(['-s', 'underscore', command], function(data) { + var array = [{ 'value': 1 }], + basename = path.basename(data.outputPath, '.js'), + context = createContext(); - ok(_.isEqual(array, clone), basename); - notEqual(array[0], clone[0], basename); - start(); + vm.runInContext(data.source, context, true); + var lodash = context._; + + _.each(index ? ['clone','cloneDeep'] : ['clone'], function(methodName) { + var clone = (methodName == 'clone') + ? lodash.clone(array, true) + : lodash.cloneDeep(array); + + ok(_.isEqual(array, clone), basename); + notEqual(array[0], clone[0], basename); + }); + + start(); + }); }); }); }());