File tree Expand file tree Collapse file tree 6 files changed +28
-5
lines changed Expand file tree Collapse file tree 6 files changed +28
-5
lines changed Original file line number Diff line number Diff line change 6
6
7
7
### Fixes
8
8
9
+ - ` [@jest/expect-utils] ` Fix deep equality of ImmutableJS Lists ([ #12763 ] ( https://github.com/facebook/jest/pull/12763 ) )
10
+
9
11
### Chore & Maintenance
10
12
11
13
- ` [@jest-reporters] ` Move helper functions from ` utils.ts ` into separate files ([ #12782 ] ( https://github.com/facebook/jest/pull/12782 ) )
Original file line number Diff line number Diff line change 20
20
"jest-get-type" : " ^28.0.2"
21
21
},
22
22
"devDependencies" : {
23
+ "immutable" : " ^4.0.0" ,
23
24
"jest-matcher-utils" : " ^28.0.2"
24
25
},
25
26
"engines" : {
Original file line number Diff line number Diff line change 6
6
*
7
7
*/
8
8
9
+ import { List } from 'immutable' ;
9
10
import { stringify } from 'jest-matcher-utils' ;
10
11
import {
11
12
arrayBufferEquality ,
@@ -517,6 +518,13 @@ describe('iterableEquality', () => {
517
518
518
519
expect ( iterableEquality ( a , b ) ) . toBe ( true ) ;
519
520
} ) ;
521
+
522
+ test ( 'returns true when given Immutable Lists without an OwnerID' , ( ) => {
523
+ const a = List ( [ 1 , 2 , 3 ] ) ;
524
+ const b = a . filter ( v => v > 0 ) ;
525
+
526
+ expect ( iterableEquality ( a , b ) ) . toBe ( true ) ;
527
+ } ) ;
520
528
} ) ;
521
529
522
530
describe ( 'arrayBufferEquality' , ( ) => {
Original file line number Diff line number Diff line change @@ -238,9 +238,10 @@ function isDomNode(obj: any): boolean {
238
238
) ;
239
239
}
240
240
241
- // SENTINEL constants are from https://github.com/facebook /immutable-js
241
+ // SENTINEL constants are from https://github.com/immutable-js /immutable-js/tree/main/src/predicates
242
242
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@' ;
243
243
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@' ;
244
+ const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@' ;
244
245
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@' ;
245
246
246
247
export function isImmutableUnorderedKeyed ( maybeKeyed : any ) {
@@ -258,3 +259,10 @@ export function isImmutableUnorderedSet(maybeSet: any) {
258
259
! maybeSet [ IS_ORDERED_SENTINEL ]
259
260
) ;
260
261
}
262
+
263
+ export function isImmutableList ( maybeList : any ) {
264
+ return ! ! (
265
+ maybeList &&
266
+ maybeList [ IS_LIST_SENTINEL ]
267
+ ) ;
268
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {isPrimitive} from 'jest-get-type';
10
10
import {
11
11
equals ,
12
12
isA ,
13
+ isImmutableList ,
13
14
isImmutableUnorderedKeyed ,
14
15
isImmutableUnorderedSet ,
15
16
} from './jasmineUtils' ;
@@ -254,10 +255,12 @@ export const iterableEquality = (
254
255
return false ;
255
256
}
256
257
257
- const aEntries = Object . entries ( a ) ;
258
- const bEntries = Object . entries ( b ) ;
259
- if ( ! equals ( aEntries , bEntries ) ) {
260
- return false ;
258
+ if ( ! isImmutableList ( a ) ) {
259
+ const aEntries = Object . entries ( a ) ;
260
+ const bEntries = Object . entries ( b ) ;
261
+ if ( ! equals ( aEntries , bEntries ) ) {
262
+ return false ;
263
+ }
261
264
}
262
265
263
266
// Remove the first value from the stack of traversed values.
Original file line number Diff line number Diff line change @@ -2606,6 +2606,7 @@ __metadata:
2606
2606
version: 0.0.0-use.local
2607
2607
resolution: "@jest/expect-utils@workspace:packages/expect-utils"
2608
2608
dependencies:
2609
+ immutable: ^4.0.0
2609
2610
jest-get-type: ^28.0.2
2610
2611
jest-matcher-utils: ^28.0.2
2611
2612
languageName: unknown
You can’t perform that action at this time.
0 commit comments