1
1
import assert from 'assert' ;
2
2
import lodashStable from 'lodash' ;
3
- import { falsey , stubObject , primitives , stubTrue } from './utils.js' ;
3
+ import { falsey , primitives , stubTrue } from './utils.js' ;
4
4
import create from '../create.js' ;
5
5
import keys from '../keys.js' ;
6
6
@@ -27,13 +27,17 @@ describe('create', function() {
27
27
28
28
it ( 'should assign `properties` to the created object' , function ( ) {
29
29
var expected = { 'constructor' : Circle , 'radius' : 0 } ;
30
+ var properties = Object . keys ( expected ) ;
30
31
Circle . prototype = create ( Shape . prototype , expected ) ;
31
32
32
33
var actual = new Circle ;
33
34
34
35
assert . ok ( actual instanceof Circle ) ;
35
36
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
+ } ) ;
37
41
} ) ;
38
42
39
43
it ( 'should assign own properties' , function ( ) {
@@ -43,7 +47,14 @@ describe('create', function() {
43
47
}
44
48
Foo . prototype . b = 2 ;
45
49
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
+ } ) ;
47
58
} ) ;
48
59
49
60
it ( 'should assign properties that shadow those of `prototype`' , function ( ) {
@@ -55,23 +66,23 @@ describe('create', function() {
55
66
} ) ;
56
67
57
68
it ( 'should accept a falsey `prototype`' , function ( ) {
58
- var expected = lodashStable . map ( falsey , stubObject ) ;
59
-
60
69
var actual = lodashStable . map ( falsey , function ( prototype , index ) {
61
70
return index ? create ( prototype ) : create ( ) ;
62
71
} ) ;
63
72
64
- assert . deepStrictEqual ( actual , expected ) ;
73
+ actual . forEach ( ( value ) => {
74
+ assert . ok ( lodashStable . isObject ( value ) ) ;
75
+ } ) ;
65
76
} ) ;
66
77
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 ( ) {
70
79
var actual = lodashStable . map ( primitives , function ( value , index ) {
71
- return lodashStable . isPlainObject ( index ? create ( value ) : create ( ) ) ;
80
+ return index ? create ( value ) : create ( ) ;
72
81
} ) ;
73
82
74
- assert . deepStrictEqual ( actual , expected ) ;
83
+ actual . forEach ( ( value ) => {
84
+ assert . ok ( lodashStable . isObject ( value ) ) ;
85
+ } ) ;
75
86
} ) ;
76
87
77
88
it ( 'should work as an iteratee for methods like `_.map`' , function ( ) {
0 commit comments