Skip to content

Commit

Permalink
fix(deep): fixed deepEqual when prop is null
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewzolotukhin committed May 20, 2023
1 parent 6507e5f commit a36ab3f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/async/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
},
"type": "module",
"types": "./dist/index.d.ts",
"version": "1.1.1"
"version": "1.1.2"
}
2 changes: 1 addition & 1 deletion libs/deep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
},
"type": "module",
"types": "./dist/index.d.ts",
"version": "1.1.1"
"version": "1.1.2"
}
34 changes: 34 additions & 0 deletions libs/deep/src/deepEqual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion libs/deep/src/deepEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "[email protected]"
},
"dependencies": {
"@cleverbrush/schema": "1.1.1"
"@cleverbrush/schema": "1.1.2"
},
"description": "Job Scheduler for NodeJS",
"files": [
Expand Down Expand Up @@ -38,5 +38,5 @@
"tsconfig": "./tsconfig.json"
},
"types": "./dist/index.d.ts",
"version": "1.1.1"
"version": "1.1.2"
}
4 changes: 2 additions & 2 deletions libs/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a36ab3f

Please sign in to comment.