@@ -58,43 +58,56 @@ describe('getDiff', () => {
58
58
const testObjectB = { arr : [ 'three' , 'two' , 'one' ] } ;
59
59
const difference = diffler ( testObjectA , testObjectB ) ;
60
60
assert . strictEqual ( Object . keys ( difference ) . length , 1 ) ;
61
- assert . deepStrictEqual ( difference , { arr : { 0 : { from : 'one' , to : 'three' } , 2 : { from : 'three' , to : 'one' } } } ) ;
61
+ assert . deepStrictEqual ( difference , {
62
+ arr : {
63
+ 0 : { from : 'one' , to : 'three' } ,
64
+ 2 : { from : 'three' , to : 'one' } ,
65
+ } ,
66
+ } ) ;
62
67
} ) ;
63
68
64
69
it ( 'returns false when array order shifted but respectArrayOrder is false' , ( ) => {
65
70
const testObjectA = { arr : [ 'one' , 'two' , 'three' ] } ;
66
71
const testObjectB = { arr : [ 'three' , 'two' , 'one' ] } ;
67
- const difference = diffler ( testObjectA , testObjectB , { respectArrayOrder : false } ) ;
72
+ const difference = diffler ( testObjectA , testObjectB , {
73
+ respectArrayOrder : false ,
74
+ } ) ;
68
75
assert . strictEqual ( Object . keys ( difference ) . length , 0 ) ;
69
76
assert . deepStrictEqual ( difference , { } ) ;
70
77
} ) ;
71
78
72
79
it ( 'returns false when array order shifted but respectArrayOrder is false as numbers' , ( ) => {
73
80
const testObjectA = { arr : [ 1 , 2 , 3 ] } ;
74
81
const testObjectB = { arr : [ 2 , 3 , 1 ] } ;
75
- const difference = diffler ( testObjectA , testObjectB , { respectArrayOrder : false } ) ;
82
+ const difference = diffler ( testObjectA , testObjectB , {
83
+ respectArrayOrder : false ,
84
+ } ) ;
76
85
assert . strictEqual ( Object . keys ( difference ) . length , 0 ) ;
77
86
assert . deepStrictEqual ( difference , { } ) ;
78
87
} ) ;
79
88
80
89
it ( 'returns false when array order shifted but respectArrayOrder is false as mixed' , ( ) => {
81
90
const testObjectA = { arr : [ 1 , 'two' , 3 ] } ;
82
91
const testObjectB = { arr : [ 'two' , 3 , 1 ] } ;
83
- const difference = diffler ( testObjectA , testObjectB , { respectArrayOrder : false } ) ;
92
+ const difference = diffler ( testObjectA , testObjectB , {
93
+ respectArrayOrder : false ,
94
+ } ) ;
84
95
assert . strictEqual ( Object . keys ( difference ) . length , 0 ) ;
85
96
assert . deepStrictEqual ( difference , { } ) ;
86
97
} ) ;
87
98
88
- it ( 'returns diff when array order shifted for non-primitives and respectArrayOrder is false' , ( ) => {
99
+ it ( 'returns no diff when array order shifted for non-primitives and respectArrayOrder is false' , ( ) => {
89
100
const testObjectA = {
90
- myArray : [ { foo : 'bar' } , { baz : 'bat' } ] ,
101
+ myArray : [ 'a string' , { foo : 'bar' } , 1 , { baz : 'bat' } ] ,
91
102
} ;
92
103
93
104
const testObjectB = {
94
- myArray : [ { baz : 'bat' } , { foo : 'bar' } ] ,
105
+ myArray : [ { baz : 'bat' } , { foo : 'bar' } , 1 , 'a string' ] ,
95
106
} ;
96
- const difference = diffler ( testObjectA , testObjectB , { respectArrayOrder : false } ) ;
97
- assert . strictEqual ( Object . keys ( difference ) . length , 1 ) ;
107
+ const difference = diffler ( testObjectA , testObjectB , {
108
+ respectArrayOrder : false ,
109
+ } ) ;
110
+ assert . strictEqual ( Object . keys ( difference ) . length , 0 ) ;
98
111
assert . deepStrictEqual ( difference , { } ) ;
99
112
} ) ;
100
113
@@ -103,23 +116,32 @@ describe('getDiff', () => {
103
116
const testObjectB = { arr : [ 'one' , 'two' , 'three' ] } ;
104
117
const difference = diffler ( testObjectA , testObjectB ) ;
105
118
assert . strictEqual ( Object . keys ( difference ) . length , 1 ) ;
106
- assert . deepStrictEqual ( difference , { arr : { 2 : { from : null , to : 'three' } } } ) ;
119
+ assert . deepStrictEqual ( difference , {
120
+ arr : { 2 : { from : null , to : 'three' } } ,
121
+ } ) ;
107
122
} ) ;
108
123
109
124
it ( 'returns change when array item removed' , ( ) => {
110
125
const testObjectA = { arr : [ 'one' , 'two' , 'three' ] } ;
111
126
const testObjectB = { arr : [ 'one' , 'two' ] } ;
112
127
const difference = diffler ( testObjectA , testObjectB ) ;
113
128
assert . strictEqual ( Object . keys ( difference ) . length , 1 ) ;
114
- assert . deepStrictEqual ( difference , { arr : { 2 : { from : 'three' , to : null } } } ) ;
129
+ assert . deepStrictEqual ( difference , {
130
+ arr : { 2 : { from : 'three' , to : null } } ,
131
+ } ) ;
115
132
} ) ;
116
133
117
134
it ( 'returns change and removal when array item removed from middle' , ( ) => {
118
135
const testObjectA = { arr : [ 'one' , 'two' , 'three' ] } ;
119
136
const testObjectB = { arr : [ 'one' , 'three' ] } ;
120
137
const difference = diffler ( testObjectA , testObjectB ) ;
121
138
assert . strictEqual ( Object . keys ( difference ) . length , 1 ) ;
122
- assert . deepStrictEqual ( difference , { arr : { 1 : { from : 'two' , to : 'three' } , 2 : { from : 'three' , to : null } } } ) ;
139
+ assert . deepStrictEqual ( difference , {
140
+ arr : {
141
+ 1 : { from : 'two' , to : 'three' } ,
142
+ 2 : { from : 'three' , to : null } ,
143
+ } ,
144
+ } ) ;
123
145
} ) ;
124
146
} ) ;
125
147
0 commit comments