Skip to content

Commit b40ef0b

Browse files
committed
Fixes ImmutableList case and adds test
1 parent f3586a7 commit b40ef0b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

packages/expect-utils/src/__tests__/utils.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
*/
88

9+
import {List} from 'immutable';
910
import {stringify} from 'jest-matcher-utils';
1011
import {
1112
arrayBufferEquality,
@@ -517,6 +518,13 @@ describe('iterableEquality', () => {
517518

518519
expect(iterableEquality(a, b)).toBe(true);
519520
});
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+
});
520528
});
521529

522530
describe('arrayBufferEquality', () => {

packages/expect-utils/src/utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,7 @@ export const iterableEquality = (
181181
if (a.size !== undefined) {
182182
if (a.size !== b.size) {
183183
return false;
184-
} else if (
185-
isA('Set', a) ||
186-
isImmutableUnorderedSet(a) ||
187-
isImmutableList(a)
188-
) {
184+
} else if (isA('Set', a) || isImmutableUnorderedSet(a)) {
189185
let allFound = true;
190186
for (const aValue of a) {
191187
if (!b.has(aValue)) {
@@ -259,6 +255,11 @@ export const iterableEquality = (
259255
return false;
260256
}
261257

258+
if (isImmutableList(a)) {
259+
// After iteration, Immutable Lists are equal
260+
return true;
261+
}
262+
262263
const aEntries = Object.entries(a);
263264
const bEntries = Object.entries(b);
264265
if (!equals(aEntries, bEntries)) {

0 commit comments

Comments
 (0)