UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

70 lines (69 loc) 2.46 kB
import { isEmpty } from './isEmpty'; describe('isEmpty', () => { it('should return true if value is ""', () => { const value = ''; expect(isEmpty(value)).toBe(true); }); it('should return true if value is ""', () => { const value = ' '; expect(isEmpty(value)).toBe(true); }); it('should return false if value is a non empty string', () => { const value = 'yes'; expect(isEmpty(value)).toBe(false); }); it('should return true if value is undefined', () => { const value = undefined; expect(isEmpty(value)).toBe(true); }); it('should return true if value is not provided', () => { let value; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore expect(isEmpty(value)).toBe(true); }); it('should return true if value is undefined', () => { const value = undefined; expect(isEmpty(value)).toBe(true); }); it('should return true if value is null', () => { const value = null; expect(isEmpty(value)).toBe(true); }); it('should return true if value is an empty array', () => { const value = []; expect(isEmpty(value)).toBe(true); }); it('should return false if value is not an empty array', () => { const value = ['a']; expect(isEmpty(value)).toBe(false); }); it('should return true if value is an empty object', () => { const value = {}; expect(isEmpty(value)).toBe(true); }); it('should return false if value is not an empty object', () => { const value = { a: 'a' }; expect(isEmpty(value)).toBe(false); }); it('should return false if value is a number', () => { const value = 1; expect(isEmpty(value)).toBe(false); }); it('should return true if value is an empty set', () => { const value = new Set(); expect(isEmpty(value)).toBe(true); }); it('should return false if value is not an empty set', () => { const value = new Set(['a']); expect(isEmpty(value)).toBe(false); }); it('should return true if value is an empty map', () => { const value = new Map(); expect(isEmpty(value)).toBe(true); }); it('should return false if value is not an empty map', () => { const value = new Map([['a', 'a']]); expect(isEmpty(value)).toBe(false); }); });