File tree 4 files changed +24
-2
lines changed
packages/expect-utils/src
4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Fixes
6
6
7
+ - ` [@jest/expect-utils] ` Fix deep equality of ImmutableJS OrderedSets ([ #12977 ] ( https://github.com/facebook/jest/pull/12977 ) )
8
+
7
9
### Chore & Maintenance
8
10
9
11
### Performance
Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
- import { List , OrderedMap } from 'immutable' ;
9
+ import { List , OrderedMap , OrderedSet } from 'immutable' ;
10
10
import { stringify } from 'jest-matcher-utils' ;
11
11
import {
12
12
arrayBufferEquality ,
@@ -531,6 +531,12 @@ describe('iterableEquality', () => {
531
531
const b = OrderedMap ( ) . merge ( { saving : true } ) ;
532
532
expect ( iterableEquality ( a , b ) ) . toBe ( true ) ;
533
533
} ) ;
534
+
535
+ test ( 'returns true when given Immutable OrderedSets without an OwnerID' , ( ) => {
536
+ const a = OrderedSet ( ) . add ( 'newValue' ) ;
537
+ const b = List ( [ 'newValue' ] ) . toOrderedSet ( ) ;
538
+ expect ( iterableEquality ( a , b ) ) . toBe ( true ) ;
539
+ } ) ;
534
540
} ) ;
535
541
536
542
describe ( 'arrayBufferEquality' , ( ) => {
Original file line number Diff line number Diff line change @@ -274,3 +274,12 @@ export function isImmutableOrderedKeyed(maybeKeyed: any) {
274
274
maybeKeyed [ IS_ORDERED_SENTINEL ]
275
275
) ;
276
276
}
277
+
278
+
279
+ export function isImmutableOrderedSet ( maybeSet : any ) {
280
+ return ! ! (
281
+ maybeSet &&
282
+ maybeSet [ IS_SET_SENTINEL ] &&
283
+ maybeSet [ IS_ORDERED_SENTINEL ]
284
+ ) ;
285
+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
isA ,
13
13
isImmutableList ,
14
14
isImmutableOrderedKeyed ,
15
+ isImmutableOrderedSet ,
15
16
isImmutableUnorderedKeyed ,
16
17
isImmutableUnorderedSet ,
17
18
} from './jasmineUtils' ;
@@ -256,7 +257,11 @@ export const iterableEquality = (
256
257
return false ;
257
258
}
258
259
259
- if ( ! isImmutableList ( a ) && ! isImmutableOrderedKeyed ( a ) ) {
260
+ if (
261
+ ! isImmutableList ( a ) &&
262
+ ! isImmutableOrderedKeyed ( a ) &&
263
+ ! isImmutableOrderedSet ( a )
264
+ ) {
260
265
const aEntries = Object . entries ( a ) ;
261
266
const bEntries = Object . entries ( b ) ;
262
267
if ( ! equals ( aEntries , bEntries ) ) {
You can’t perform that action at this time.
0 commit comments