-
Notifications
You must be signed in to change notification settings - Fork 388
/
isDeepEmpty.test.ts
47 lines (35 loc) · 1.19 KB
/
isDeepEmpty.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {expect, it} from '@jest/globals'
import {isDeepEmpty} from '../isDeepEmpty'
it('returns true for undefined', () => {
expect(isDeepEmpty(undefined)).toBe(true)
})
it('returns true for null', () => {
expect(isDeepEmpty(null)).toBe(true)
})
it('returns true for an empty object', () => {
expect(isDeepEmpty({})).toBe(true)
})
it('returns true for an object with only empty values', () => {
expect(isDeepEmpty({a: {}, b: {c: {}}})).toBe(true)
})
it('returns false for an object with non-empty values', () => {
expect(isDeepEmpty({a: {}, b: {c: {}}, d: 1})).toBe(false)
})
it('returns true for an empty array', () => {
expect(isDeepEmpty([])).toBe(true)
})
it('returns true for an array with only empty values', () => {
expect(isDeepEmpty([[], [[]]])).toBe(true)
})
it('returns false for an array with non-empty values', () => {
expect(isDeepEmpty([[], [[]], 1])).toBe(false)
})
it('returns false for a non-empty object', () => {
expect(isDeepEmpty({a: 1})).toBe(false)
})
it('returns false for a non-empty array', () => {
expect(isDeepEmpty([1])).toBe(false)
})
it('ignores _type and _key properties', () => {
expect(isDeepEmpty({_type: 'foo', _key: 'bar', a: {}})).toBe(true)
})