import { Map, List } from 'immutable'

import SessionItemResult from '../../SessionItemResult'
import SessionItemResultsList from '../index'
import SessionItem from '../../../../../records/SessionItem'
import SessionItemResultRecord from '../../../../../records/SessionItemResult'
import Item from '../../../../../records/Item'

import QuizSession from '../../../../../records/QuizSession'

describe('SessionItemResultsList Presenter', () => {
  const item1 = new Item({id: '1'})
  item1.getInteractionType = () => ({slug: 'foo'})
  const item2 = new Item({id: '2', itemBody: 'test'})
  item2.getInteractionType = () => ({slug: 'foo'})
  const testbed = createTestbed(withContext(SessionItemResultsList), {
    quizSession: new QuizSession({user: Map()}),
    quizSessionResults: List(),
    sessionItems: List([
      new SessionItem({position: '1', item: item1, id: 1}),
      new SessionItem({position: '2', item: item2, id: 2})
    ]),
    sessionItemResults: List([
      new SessionItemResultRecord({position: '1'}),
      new SessionItemResultRecord({position: '2'})
    ])
  })

  shouldRenderComponent(testbed, {}, SessionItemResultsList)

  it('should render items results', () => {
    testbed.render({})
    const results = testbed.findChildrenByType(SessionItemResult)
    expect(results.length).to.equal(2)
  })

  describe('a11y tests', () => {
    it('should meet a11y standards', (done) => {
      testbed.render({})
      testbed.checkA11yStandards(done)
    })
  })
})
