import { expect } from 'chai'
import { startEdit, endEdit, toggleEditing } from '../editing'
import { START_EDIT, END_EDIT, TOGGLE_EDIT } from '@instructure/quiz-common/lib/constants'

describe('editing action creators', () => {
  it('returns a well-formed start edit action', () => {
    const startEditAction = startEdit('someUniqKey')

    expect(startEditAction)
      .to.deep.equal({
        type: START_EDIT,
        componentId: 'someUniqKey',
        initialFocusId: null
      })
  })

  it('returns a well-formed start edit action with initial focus id', () => {
    const startEditAction = startEdit('someUniqKey', 'initial_focus_id')

    expect(startEditAction)
      .to.deep.equal({
        type: START_EDIT,
        componentId: 'someUniqKey',
        initialFocusId: 'initial_focus_id'
      })
  })

  it('returns a well-formed end edit action', () => {
    const endEditAction = endEdit('someOtherUniqKey')

    expect(endEditAction)
      .to.deep.equal({
        type: END_EDIT,
        componentId: 'someOtherUniqKey'
      })
  })

  it('returns a well-formed toggle edit action', () => {
    const endEditAction = toggleEditing('someOtherUniqKey')

    expect(endEditAction)
      .to.deep.equal({
        type: TOGGLE_EDIT,
        componentId: 'someOtherUniqKey'
      })
  })
})
