import { expect } from 'chai'

import {
  addQuizzes,
  disassociateQuizEntry,
  newActiveQuiz
} from '../quizzes'

import {
  ACTIVE_QUIZ_CHANGE,
  ADD_QUIZZES,
  DISASSOCIATE_QUIZ_ENTRY
} from '@instructure/quiz-common/lib/constants'

describe('quizzes action creators', () => {
  it('returns a addQuizzes action ', () => {
    const quizzes = [{id: '1', title: 'test'}, {id: '2', title: 'test 2'}]
    const addQuizzesAction = addQuizzes(quizzes)
    const expectedAction = {
      type: ADD_QUIZZES,
      payload: quizzes
    }

    expect(addQuizzesAction)
      .to.deep.equal(expectedAction)
  })

  it('returns a well-formed activeQuizId change action', () => {
    const newActiveQuizAction = newActiveQuiz('12')

    expect(newActiveQuizAction)
      .to.deep.equal({
        type: ACTIVE_QUIZ_CHANGE,
        payload: '12'
      })
  })

  it('returns a proper disassociateQuizEntry action', () => {
    const disassocItemAction = disassociateQuizEntry('1', '2')
    const expectedAction = {
      type: DISASSOCIATE_QUIZ_ENTRY,
      payload: {quizId: '1', quizEntryId: '2'}
    }

    expect(disassocItemAction)
      .to.deep.equal(expectedAction)
  })
})
