diff --git a/CHANGELOG.md b/CHANGELOG.md index d14ba70e1299..ca451947a7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ ### Fixes -- `[jest-worker]` Make `JestWorkerFarm` helper type to include methods of worker module that take more than one argument ([#12839](https://github.com/facebook/jest/pull/12839)) +- `[@jest/expect-utils]` Fix deep equality of ImmutableJS OrderedMaps ([#12763](https://github.com/facebook/jest/pull/12899)) - `[jest-docblock]` Handle multiline comments in parseWithComments ([#12845](https://github.com/facebook/jest/pull/12845)) +- `[jest-worker]` Make `JestWorkerFarm` helper type to include methods of worker module that take more than one argument ([#12839](https://github.com/facebook/jest/pull/12839)) ### Chore & Maintenance diff --git a/packages/expect-utils/src/__tests__/utils.test.ts b/packages/expect-utils/src/__tests__/utils.test.ts index d5fc11521e75..e94c72e5c191 100644 --- a/packages/expect-utils/src/__tests__/utils.test.ts +++ b/packages/expect-utils/src/__tests__/utils.test.ts @@ -6,7 +6,7 @@ * */ -import {List} from 'immutable'; +import {List, OrderedMap} from 'immutable'; import {stringify} from 'jest-matcher-utils'; import { arrayBufferEquality, @@ -525,6 +525,12 @@ describe('iterableEquality', () => { expect(iterableEquality(a, b)).toBe(true); }); + + test('returns true when given Immutable OrderedMaps without an OwnerID', () => { + const a = OrderedMap().set('saving', true); + const b = OrderedMap().merge({saving: true}); + expect(iterableEquality(a, b)).toBe(true); + }); }); describe('arrayBufferEquality', () => { diff --git a/packages/expect-utils/src/jasmineUtils.ts b/packages/expect-utils/src/jasmineUtils.ts index 552265c65764..6b003ed89569 100644 --- a/packages/expect-utils/src/jasmineUtils.ts +++ b/packages/expect-utils/src/jasmineUtils.ts @@ -266,3 +266,11 @@ export function isImmutableList(maybeList: any) { maybeList[IS_LIST_SENTINEL] ); } + +export function isImmutableOrderedKeyed(maybeKeyed: any) { + return !!( + maybeKeyed && + maybeKeyed[IS_KEYED_SENTINEL] && + maybeKeyed[IS_ORDERED_SENTINEL] + ); +} diff --git a/packages/expect-utils/src/utils.ts b/packages/expect-utils/src/utils.ts index a16522eb38e6..684a184a6370 100644 --- a/packages/expect-utils/src/utils.ts +++ b/packages/expect-utils/src/utils.ts @@ -11,6 +11,7 @@ import { equals, isA, isImmutableList, + isImmutableOrderedKeyed, isImmutableUnorderedKeyed, isImmutableUnorderedSet, } from './jasmineUtils'; @@ -255,7 +256,7 @@ export const iterableEquality = ( return false; } - if (!isImmutableList(a)) { + if (!isImmutableList(a) && !isImmutableOrderedKeyed(a)) { const aEntries = Object.entries(a); const bEntries = Object.entries(b); if (!equals(aEntries, bEntries)) {