Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/cli-kit/src/public/common/object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
deepDifference,
deepMergeObjects,
getPathValue,
isEmpty,
mapValues,
pickBy,
setPathValue,
Expand Down Expand Up @@ -364,6 +365,26 @@ describe('compact', () => {
})
})

describe('isEmpty', () => {
test('returns true for empty objects, arrays, maps, sets, strings, and nil values', () => {
expect(isEmpty({})).toBe(true)
expect(isEmpty([])).toBe(true)
expect(isEmpty(new Map())).toBe(true)
expect(isEmpty(new Set())).toBe(true)
expect(isEmpty('' as unknown as object)).toBe(true)
expect(isEmpty(null as unknown as object)).toBe(true)
expect(isEmpty(undefined as unknown as object)).toBe(true)
})

test('returns false for non-empty objects, arrays, maps, sets, and strings', () => {
expect(isEmpty({key: 'value'})).toBe(false)
expect(isEmpty([1])).toBe(false)
expect(isEmpty(new Map([['key', 'value']]))).toBe(false)
expect(isEmpty(new Set([1]))).toBe(false)
expect(isEmpty('text' as unknown as object)).toBe(false)
})
})

describe('unsetPathValue', () => {
test('removes the path value at the top level if it exists', () => {
// Given
Expand Down
Loading