import * as fc from 'fast-check'
import isEmpty from './isEmpty'

it('should exist', () => {
  expect(isEmpty).toBeDefined()
})

it('should be a function', () => {
  expect(typeof isEmpty).toBe('function')
})

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)
      }),
    )
  })
})
