@qntm-code/utils
Version:
A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.
56 lines (55 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const isEmpty_1 = require("./isEmpty");
describe('isEmpty', () => {
it('should return true if value is ""', () => {
const value = '';
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return true if value is ""', () => {
const value = ' ';
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return false if value is a non empty string', () => {
const value = 'yes';
expect((0, isEmpty_1.isEmpty)(value)).toBe(false);
});
it('should return true if value is undefined', () => {
const value = undefined;
expect((0, isEmpty_1.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((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return true if value is undefined', () => {
const value = undefined;
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return true if value is null', () => {
const value = null;
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return true if value is an empty array', () => {
const value = [];
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return false if value is not an empty array', () => {
const value = ['a'];
expect((0, isEmpty_1.isEmpty)(value)).toBe(false);
});
it('should return true if value is an empty object', () => {
const value = {};
expect((0, isEmpty_1.isEmpty)(value)).toBe(true);
});
it('should return false if value is not an empty object', () => {
const value = { a: 'a' };
expect((0, isEmpty_1.isEmpty)(value)).toBe(false);
});
it('should return false if value is a number', () => {
const value = 1;
expect((0, isEmpty_1.isEmpty)(value)).toBe(false);
});
});