// failure to import matchesSnapshot
import { Cog } from '@procore/core-icons/dist'
import React from 'react'
import { matchesSnapshot } from '../../__tests__/helpers/snapshots'
import { SourceItem } from './SourceItem'

describe('SourceItem', () => {
  it('default view', () => {
    matchesSnapshot(<SourceItem />)
  })

  it('DivAttributes', () => {
    matchesSnapshot(<SourceItem className="TEST" tabIndex={100} />)
  })

  it('error view', () => {
    matchesSnapshot(<SourceItem error />)
  })

  it('loading view', () => {
    matchesSnapshot(<SourceItem loading />)
  })

  it('selected view', () => {
    matchesSnapshot(<SourceItem selected />)
  })

  it('disabled view', () => {
    matchesSnapshot(<SourceItem disabled />)
  })

  it('icon and label', () => {
    matchesSnapshot(<SourceItem icon={<Cog />}>Label</SourceItem>)
  })

  describe('count', () => {
    it('equal to 0 should not be rendered', () => {
      matchesSnapshot(<SourceItem count={0} />)
    })

    it('should be rendered as is in parentheses when larger then 0 and less then 100', () => {
      matchesSnapshot(<SourceItem count={24} />)
    })

    it('should be rendered truncated in parentheses when larger then 99', () => {
      matchesSnapshot(<SourceItem count={100} />)
    })

    it('should be rendered truncated in parentheses when equal or larger then custom threshold', () => {
      matchesSnapshot(<SourceItem count={11} countTruncationThreshold={10} />)
    })
  })
})
