import * as fc from 'fast-check' import isEmpty from './isEmpty' describe('lib/services/isEmpty', () => { it('should exist', () => { expect(isEmpty).toBeDefined() }) it('should be a function', () => { expect(isEmpty).toBeFunction() }) it('should accept 1 argument', () => { expect(isEmpty).toHaveLength(1) }) it('should return a boolean value', () => { fc.assert( fc.property(fc.anything(), (v) => { expect(typeof isEmpty(v)).toBe('boolean') }), ) }) describe('on arguments', () => { it('should return `true` on an argument with value of `undefined`', () => { expect(isEmpty(undefined)).toBe(true) }) it('should return `true` on an argument with value of `null`', () => { expect(isEmpty(null)).toBe(true) }) it('should return `false` on an argument with value that is neither `undefined` nor `null`', () => { fc.assert( fc.property(fc.anything().filter((v) => typeof v !== 'undefined' && v !== null), (v) => { expect(isEmpty(v)).toBe(false) }), ) }) }) })