import { useSkeleton } from 'components'
import { renderHook } from '@testing-library/react'
import { SkeletonProps } from '../skeleton-types'

describe('UseSkeleton', () => {
  it('should return skeleton when loading', () => {
    const component = 'lazy'
    const { result } = renderHook(() => useSkeleton(component, true))

    const element = result.current as any
    expect(element.type.name).toEqual('Skeleton')
  })

  it('should pass props to skeleton', () => {
    const component = 'lazy'
    const options: SkeletonProps = { size: 'mini', unit: '%' }
    const { result } = renderHook(() => useSkeleton(component, true, options))

    expect((result.current as any).props).toEqual(options)
  })

  it('should return component when not loading', () => {
    const component = 'lazy'
    const { result } = renderHook(() => useSkeleton(component, false))

    expect(result.current).toEqual(component)
  })
})
