Skip to content

Commit 9971765

Browse files
blikblumjdalton
authored andcommitted
Enable create tests and adapt it for the new primitive prototype behavior (#4418)
* Enable create tests and adapt it for the new primitive prototype behavior * Use isObject in create tests instead of manual check * Store properties in a variable when used more than once in create tests * Add parens around arrow function params in create tests
1 parent e5f8407 commit 9971765

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/create.js renamed to test/create.test.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'assert';
22
import lodashStable from 'lodash';
3-
import { falsey, stubObject, primitives, stubTrue } from './utils.js';
3+
import { falsey, primitives, stubTrue } from './utils.js';
44
import create from '../create.js';
55
import keys from '../keys.js';
66

@@ -27,13 +27,17 @@ describe('create', function() {
2727

2828
it('should assign `properties` to the created object', function() {
2929
var expected = { 'constructor': Circle, 'radius': 0 };
30+
var properties = Object.keys(expected);
3031
Circle.prototype = create(Shape.prototype, expected);
3132

3233
var actual = new Circle;
3334

3435
assert.ok(actual instanceof Circle);
3536
assert.ok(actual instanceof Shape);
36-
assert.deepStrictEqual(Circle.prototype, expected);
37+
assert.deepStrictEqual(Object.keys(Circle.prototype), properties);
38+
properties.forEach((property) => {
39+
assert.strictEqual(Circle.prototype[property], expected[property]);
40+
});
3741
});
3842

3943
it('should assign own properties', function() {
@@ -43,7 +47,14 @@ describe('create', function() {
4347
}
4448
Foo.prototype.b = 2;
4549

46-
assert.deepStrictEqual(create({}, new Foo), { 'a': 1, 'c': 3 });
50+
var actual = create({}, new Foo);
51+
var expected = { 'a': 1, 'c': 3 };
52+
var properties = Object.keys(expected);
53+
54+
assert.deepStrictEqual(Object.keys(actual), properties);
55+
properties.forEach((property) => {
56+
assert.strictEqual(actual[property], expected[property]);
57+
});
4758
});
4859

4960
it('should assign properties that shadow those of `prototype`', function() {
@@ -55,23 +66,23 @@ describe('create', function() {
5566
});
5667

5768
it('should accept a falsey `prototype`', function() {
58-
var expected = lodashStable.map(falsey, stubObject);
59-
6069
var actual = lodashStable.map(falsey, function(prototype, index) {
6170
return index ? create(prototype) : create();
6271
});
6372

64-
assert.deepStrictEqual(actual, expected);
73+
actual.forEach((value) => {
74+
assert.ok(lodashStable.isObject(value));
75+
});
6576
});
6677

67-
it('should ignore a primitive `prototype` and use an empty object instead', function() {
68-
var expected = lodashStable.map(primitives, stubTrue);
69-
78+
it('should accept a primitive `prototype`', function() {
7079
var actual = lodashStable.map(primitives, function(value, index) {
71-
return lodashStable.isPlainObject(index ? create(value) : create());
80+
return index ? create(value) : create();
7281
});
7382

74-
assert.deepStrictEqual(actual, expected);
83+
actual.forEach((value) => {
84+
assert.ok(lodashStable.isObject(value));
85+
});
7586
});
7687

7788
it('should work as an iteratee for methods like `_.map`', function() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy