import TagDisplay from '../'

import { fromJS } from 'immutable'
import Tag from '@instructure/ui-elements/lib/components/Tag'

describe('TagDisplay', () => {
  const testbed = createTestbed(TagDisplay, {})

  shouldRenderComponent(testbed, {}, TagDisplay)

  it('should render no tags', () => {
    testbed.render()
    expect(testbed.findChildrenByType(Tag).length).to.eq(0)
  })

  it('should render a single tag', () => {
    testbed.render({
      tagAssociations: fromJS([
        {
          id: '1', tag_id: '1', tag_value: 'hi'
        }
      ])
    })
    expect(testbed.findChildrenByType(Tag).length).to.eq(1)
  })

  it('renders up to two tags plus an extra pill', () => {
    testbed.render({
      tagAssociations: fromJS([
        {id: '1', tag_id: '1', tag_value: 'test1'},
        {id: '2', tag_id: '2', tag_value: 'test2'},
        {id: '3', tag_id: '3', tag_value: 'test3'},
        {id: '4', tag_id: '4', tag_value: 'test4'}
      ])
    })
    expect(testbed.findChildrenByType(Tag).length).to.eq(3)
  })
})
