From d9687e92e0315627fcb1319ac4e50d3ebd081441 Mon Sep 17 00:00:00 2001 From: Peter van Gulik Date: Tue, 13 Aug 2024 18:13:37 +0200 Subject: [PATCH] fix: unit test for compare object to match new behavior --- packages/util/src/__tests__/object.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/util/src/__tests__/object.test.ts b/packages/util/src/__tests__/object.test.ts index 3a47caff..0a3808b8 100644 --- a/packages/util/src/__tests__/object.test.ts +++ b/packages/util/src/__tests__/object.test.ts @@ -177,10 +177,15 @@ describe('util', () => { const b = { foo: [ { bar: 2 }, { bar: 1 }, { bar: 1 } ] }; expect(objectEquals(a, b, { ignoreArrayOrder: false })).toBe(false); }); - it('should return true for arrays with extra elements and ignoreExtraProperties = true and ignoreArrayOrder = true', () => { + it('should return false for arrays with extra elements and ignoreExtraProperties = true and ignoreArrayOrder = true', () => { const a = { foo: [ { bar: 1 } ] }; const b = { foo: [ { bar: 1 }, { bar: 2 } ] }; - expect(objectEquals(a, b, { ignoreExtraProperties: true, ignoreArrayOrder: true })).toBe(true); + expect(objectEquals(a, b, { ignoreExtraProperties: true, ignoreArrayOrder: true })).toBe(false); + }); + it('should return false for arrays with extra elements and ignoreExtraElements = true, ignoreExtraProperties = true and ignoreArrayOrder = true', () => { + const a = { foo: [ { bar: 1 } ] }; + const b = { foo: [ { bar: 1 }, { bar: 2 } ] }; + expect(objectEquals(a, b, { ignoreExtraProperties: true, ignoreExtraElements: true, ignoreArrayOrder: true })).toBe(true); }); it('should return true for equal primitives', () => { expect(objectEquals('a', 'a')).toBe(true);