From 1665e5cbffdfa3a7b5ded411d7a44bdf45e2c96d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 5 Oct 2016 16:11:10 -0700 Subject: [PATCH] Add bizarro `_.create` test. --- test/index.html | 6 +++--- test/test.js | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/test/index.html b/test/index.html index aee394249..e536bc2d9 100644 --- a/test/index.html +++ b/test/index.html @@ -85,9 +85,9 @@ setProperty(Object, '_create', Object.create); setProperty(Object, 'create', (function() { function object() {} - return function(prototype) { - if (prototype === Object(prototype)) { - object.prototype = prototype; + return function(proto) { + if (proto === Object(proto)) { + object.prototype = proto; var result = new object; object.prototype = undefined; } diff --git a/test/test.js b/test/test.js index 1b325b49c..0f7189acc 100644 --- a/test/test.js +++ b/test/test.js @@ -520,9 +520,9 @@ // Set bad shims. setProperty(Object, 'create', (function() { function object() {} - return function(prototype) { - if (lodashStable.isObject(prototype)) { - object.prototype = prototype; + return function(proto) { + if (lodashStable.isObject(proto)) { + object.prototype = proto; var result = new object; object.prototype = undefined; } @@ -823,7 +823,7 @@ }); QUnit.test('should avoid non-native built-ins', function(assert) { - assert.expect(7); + assert.expect(8); function message(lodashMethod, nativeMethod) { return '`' + lodashMethod + '` should avoid overwritten native `' + nativeMethod + '`'; @@ -855,6 +855,14 @@ var label = message('_.isEmpty', 'Object#propertyIsEnumerable'); assert.strictEqual(actual, true, label); + try { + actual = lodashBizarro.create(Foo.prototype); + } catch (e) { + actual = null; + } + label = message('_.create', 'Object.create'); + assert.ok(actual instanceof Foo, label); + try { actual = [ lodashBizarro.difference([object, otherObject], largeArray), @@ -920,7 +928,7 @@ assert.deepEqual(actual, [], label); } else { - skipAssert(assert, 7); + skipAssert(assert, 8); } }); }());