From fdf6478bc92ed566eb4d51d335b6ef82aabf8cd7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 19 Oct 2015 20:59:12 -0700 Subject: [PATCH] Use helper methods from the stable lodash release to test unstable bits. --- package.json | 1 + test/index.html | 2 + test/test.js | 2189 +++++++++++++++++++++++------------------------ 3 files changed, 1096 insertions(+), 1096 deletions(-) diff --git a/package.json b/package.json index 3fde0a2fe..8a2c8ae81 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "istanbul": "0.3.22", "jquery": "~1.11.0", "jscs": "^2.3.1", + "lodash": "^3.10.1", "platform": "~1.3.0", "qunit-extras": "~1.4.0", "qunitjs": "~1.19.0", diff --git a/test/index.html b/test/index.html index c5ccd10ad..d53a1ddc5 100644 --- a/test/index.html +++ b/test/index.html @@ -22,6 +22,8 @@ }; } + + diff --git a/test/test.js b/test/test.js index 46dbb4473..50f8364a9 100644 --- a/test/test.js +++ b/test/test.js @@ -214,22 +214,15 @@ QUnit = QUnit.QUnit || QUnit )); - /** Load QUnit Extras and ES6 shims. */ - (function() { - var paths = [ - '../node_modules/qunit-extras/qunit-extras.js' - ]; - - var index = -1, - length = paths.length; - - while (++index < length) { - var object = load(paths[index]); - if (object) { - object.runInContext(root); - } - } - }()); + /** Load stable Lodash and QUnit Extras. */ + var lodashStable = root.lodashStable || load('../node_modules/lodash/index.js'); + if (lodashStable) { + lodashStable.runInContext(root); + } + var QUnitExtras = load('../node_modules/qunit-extras/qunit-extras.js'); + if (QUnitExtras) { + QUnitExtras.runInContext(root); + } /** The `lodash` function to test. */ var _ = root._ || (root._ = ( @@ -347,7 +340,7 @@ * @param {Object} object The object to empty. */ function emptyObject(object) { - _.forOwn(object, function(value, key, object) { + lodashStable.forOwn(object, function(value, key, object) { delete object[key]; }); } @@ -403,7 +396,7 @@ reToString = /toString/g; function createToString(funcName) { - return _.constant(nativeString.replace(reToString, funcName)); + return lodashStable.constant(nativeString.replace(reToString, funcName)); } // Allow bypassing native checks. @@ -415,7 +408,7 @@ }); // Add prototype extensions. - funcProto._method = _.noop; + funcProto._method = noop; // Set bad shims. var _propertyIsEnumerable = objectProto.propertyIsEnumerable; @@ -438,9 +431,9 @@ setProperty(root.Map, 'toString', createToString('Map')); } - setProperty(Object, 'create', _.noop); - setProperty(root, 'Set', _.noop); - setProperty(root, 'WeakMap', _.noop); + setProperty(Object, 'create', noop); + setProperty(root, 'Set', noop); + setProperty(root, 'WeakMap', noop); // Fake `WinRTError`. setProperty(root, 'WinRTError', Error); @@ -476,8 +469,8 @@ }()); // Add other realm values from the `vm` module. - _.attempt(function() { - _.extend(realm, require('vm').runInNewContext([ + lodashStable.attempt(function() { + lodashStable.assign(realm, require('vm').runInNewContext([ '(function() {', ' var root = this;', '', @@ -513,7 +506,7 @@ }); // Add other realm values from an iframe. - _.attempt(function() { + lodashStable.attempt(function() { _._realm = realm; var iframe = document.createElement('iframe'); @@ -523,7 +516,7 @@ var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; idoc.write([ '