js-essential-kit
Version:
This library provides a comprehensive set of utility functions for various common tasks, including date calculations, formatting, masking, normalizing data, and validation
55 lines (50 loc) • 1.82 kB
text/typescript
import { isEmpty, isNotEmpty } from '../lib/utils/arraysUtils'
describe('isEmpty', () => {
test('Returns true if array is empty', () => {
expect(isEmpty([])).toBe(true)
})
test('Returns true if array is undefined', () => {
expect(isEmpty(undefined)).toBe(true)
})
test('Returns false if array is not empty', () => {
expect(isEmpty([1, 2, 3])).toBe(false)
})
test('Returns false if array contains only undefined values', () => {
expect(isEmpty([undefined, undefined])).toBe(false)
})
test('Returns false if array contains only null values', () => {
expect(isEmpty([null, null])).toBe(false)
})
test('Returns false if array contains only empty strings', () => {
expect(isEmpty(['', ''])).toBe(false)
})
test('Returns false if array contains only whitespace strings', () => {
expect(isEmpty([' ', ' '])).toBe(false)
})
test('Returns false if array contains only empty objects', () => {
expect(isEmpty([{}, {}])).toBe(false)
})
test('Returns false if array contains only empty arrays', () => {
expect(isEmpty([[], []])).toBe(false)
})
})
describe('isNotEmpty', () => {
test('Returns true if array is not empty', () => {
expect(isNotEmpty([1, 2, 3])).toBe(true)
})
test('Returns false if array is empty', () => {
expect(isNotEmpty([])).toBe(false)
})
test('Returns false if array is undefined', () => {
expect(isNotEmpty(undefined)).toBe(false)
})
test('Returns true if array contains only undefined values', () => {
expect(isNotEmpty([undefined, undefined])).toBe(true)
})
test('Returns true if array contains only whitespace strings', () => {
expect(isNotEmpty([' ', ' '])).toBe(true)
})
test('Returns true if array contains only empty arrays', () => {
expect(isNotEmpty([[], []])).toBe(true)
})
})