import { expect } from 'chai'

import MultipleAnswerEditComponent from 'quiz-interactions/lib/components/multiple_answer/Edit'
import MultipleAnswerShowComponent from 'quiz-interactions/lib/components/multiple_answer/Show'
import MultipleAnswerTakeComponent from 'quiz-interactions/lib/components/multiple_answer/Take'
import MultipleAnswerResultComponent from 'quiz-interactions/lib/components/multiple_answer/Result'

import {
  COMPONENT_EDIT,
  COMPONENT_SHOW,
  COMPONENT_TAKE,
  COMPONENT_RESULT
} from '@instructure/quiz-common/lib/constants'

import componentForItem, { UnregisteredItem } from '../componentForItem'

describe('componentForItem', () => {
  it('returns a show component if valid type and usage given', () => {
    const someComponent = componentForItem('multi-answer', COMPONENT_SHOW)

    expect(
      someComponent
    ).to.be.equal(
      MultipleAnswerShowComponent
    )
  })

  it('returns a taking component if valid type and usage given', () => {
    const someComponent = componentForItem('multi-answer', COMPONENT_TAKE)

    expect(
      someComponent
    ).to.be.equal(
      MultipleAnswerTakeComponent
    )
  })

  it('returns an editing component if valid type and usage given', () => {
    const someComponent = componentForItem('multi-answer', COMPONENT_EDIT)

    expect(
      someComponent
    ).to.be.equal(
      MultipleAnswerEditComponent
    )
  })

  it('returns an editing component if valid type and usage given', () => {
    const someComponent = componentForItem('multi-answer', COMPONENT_RESULT)

    expect(
      someComponent
    ).to.be.equal(
      MultipleAnswerResultComponent
    )
  })

  it('returns the unregistered component if invalid args given', () => {
    const someComponent = componentForItem('foo', 'bar')

    expect(
      someComponent
    ).to.be.equal(
      UnregisteredItem
    )
  })
})
