mirror of
https://github.com/dzeiocom/libs.git
synced 2025-06-07 16:49:56 +00:00
fix: handle arrays with empty elements
Signed-off-by: Avior <f.bouillon@aptatio.com>
This commit is contained in:
parent
91e44c4033
commit
a1304e7349
@ -1,6 +1,6 @@
|
|||||||
/// <reference types="jest" />
|
/// <reference types="jest" />
|
||||||
|
|
||||||
import { objectSize, objectMap, objectSort, objectEqual, objectKeys, objectSet, objectLoop, objectClone, objectValues, objectClean, isObject, objectOmit } from '../src/ObjectUtil'
|
import { isObject, objectClean, objectClone, objectEqual, objectKeys, objectLoop, objectMap, objectOmit, objectSet, objectSize, objectSort, objectValues } from '../src/ObjectUtil'
|
||||||
|
|
||||||
describe('Throw if parameter is not an object', () => {
|
describe('Throw if parameter is not an object', () => {
|
||||||
it('should works', () => {
|
it('should works', () => {
|
||||||
@ -271,6 +271,9 @@ describe('Object Equal Test', () => {
|
|||||||
a: [10, {b: 'c'}], d: '1', e: 2, f: true, g: null, h: undefined
|
a: [10, {b: 'c'}], d: '1', e: 2, f: true, g: null, h: undefined
|
||||||
})).toBe(true)
|
})).toBe(true)
|
||||||
})
|
})
|
||||||
|
it('should handle arrays with empty elements', () => {
|
||||||
|
expect(objectEqual([,true], [,true])).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Object Clean Tests', () => {
|
describe('Object Clean Tests', () => {
|
||||||
|
@ -200,7 +200,7 @@ export function objectEqual(first: BasicObject, second: BasicObject): boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const res = objectLoop(first, (item, key) => {
|
const res = objectLoop(first, (item, key) => {
|
||||||
if (!(key in second)) {
|
if (!(key in second) && key in first) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const item2 = second[key]
|
const item2 = second[key]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user