From a36ab3ff428d2cf1e2f2e2c0cb882ef6ba56f035 Mon Sep 17 00:00:00 2001 From: Andrew Zolotukhin Date: Sat, 20 May 2023 05:05:22 +0300 Subject: [PATCH] fix(deep): fixed deepEqual when prop is null --- libs/async/package.json | 2 +- libs/deep/package.json | 2 +- libs/deep/src/deepEqual.test.ts | 34 +++++++++++++++++++++++++++++++++ libs/deep/src/deepEqual.ts | 2 +- libs/scheduler/package.json | 4 ++-- libs/schema/package.json | 4 ++-- package.json | 2 +- 7 files changed, 42 insertions(+), 8 deletions(-) diff --git a/libs/async/package.json b/libs/async/package.json index 4b51edd..5e977b1 100644 --- a/libs/async/package.json +++ b/libs/async/package.json @@ -33,5 +33,5 @@ }, "type": "module", "types": "./dist/index.d.ts", - "version": "1.1.1" + "version": "1.1.2" } diff --git a/libs/deep/package.json b/libs/deep/package.json index a5bf40c..9652c9e 100644 --- a/libs/deep/package.json +++ b/libs/deep/package.json @@ -35,5 +35,5 @@ }, "type": "module", "types": "./dist/index.d.ts", - "version": "1.1.1" + "version": "1.1.2" } diff --git a/libs/deep/src/deepEqual.test.ts b/libs/deep/src/deepEqual.test.ts index 390757d..0f9523c 100644 --- a/libs/deep/src/deepEqual.test.ts +++ b/libs/deep/src/deepEqual.test.ts @@ -67,3 +67,37 @@ test('deepEqual - 12', () => { ) ).toEqual(true); }); + +test('deepEqual - null args', () => { + expect(deepEqual(null, null)).toEqual(true); +}); + +test('deepEqual - null props', () => { + expect(deepEqual({ prop1: null }, { prop1: null })).toEqual(true); +}); + +test('deepEqual - null props 2', () => { + expect( + deepEqual( + { prop1: null }, + { + prop1: { + someVal: 10 + } + } + ) + ).toEqual(false); +}); + +test('deepEqual - undefined props', () => { + expect( + deepEqual( + { prop1: undefined }, + { + prop1: { + someVal: 10 + } + } + ) + ).toEqual(false); +}); diff --git a/libs/deep/src/deepEqual.ts b/libs/deep/src/deepEqual.ts index 5eefcc6..6f8d9d3 100644 --- a/libs/deep/src/deepEqual.ts +++ b/libs/deep/src/deepEqual.ts @@ -70,7 +70,7 @@ export const deepEqual = function ( return arraysAreIdentical(o1, o2); } - if (typeof o1 === 'object') { + if (typeof o1 === 'object' && o1 !== null) { if (cache.get(o1) === true) { return false; } diff --git a/libs/scheduler/package.json b/libs/scheduler/package.json index 9ee68a4..043486c 100644 --- a/libs/scheduler/package.json +++ b/libs/scheduler/package.json @@ -5,7 +5,7 @@ "email": "andrew_zol@cleverbrush.com" }, "dependencies": { - "@cleverbrush/schema": "1.1.1" + "@cleverbrush/schema": "1.1.2" }, "description": "Job Scheduler for NodeJS", "files": [ @@ -38,5 +38,5 @@ "tsconfig": "./tsconfig.json" }, "types": "./dist/index.d.ts", - "version": "1.1.1" + "version": "1.1.2" } diff --git a/libs/schema/package.json b/libs/schema/package.json index 06d1792..2870b7b 100644 --- a/libs/schema/package.json +++ b/libs/schema/package.json @@ -35,8 +35,8 @@ "displayName": "Schema Definition And Validation", "tsconfig": "./tsconfig.json" }, - "version": "1.1.1", + "version": "1.1.2", "devDependencies": { - "@cleverbrush/deep": "1.1.1" + "@cleverbrush/deep": "1.1.2" } } diff --git a/package.json b/package.json index 462a507..c701b24 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cleverbrush-framework", "private": "true", - "version": "1.1.1", + "version": "1.1.2", "description": "Cleverbrush Framework - a set of libraries used by Cleverbrush, a web-based publishing application", "scripts": { "build": "npm run clean && npm run build_async && npm run build_deep && npm run build_schema && npm run build_scheduler",