import * as actions from '../ui'
import {
  MERGE_UI,
  SET_UI,
  TOGGLE_UI,
  OCCLUDE_QUIZ_ENTRIES,
  ACTIVE_BANK_CHANGE,
  ACTIVE_BANK_ENTRY_CHANGE
} from '@instructure/quiz-common/lib/constants'

describe('ui action creators', () => {
  describe('toggle', () => {
    it('returns a well-formed and correct action', () => {
      expect(actions.toggle('my_arbitrary_key')).to.deep.equal(
        {
          type: TOGGLE_UI,
          payload: 'my_arbitrary_key'
        }
      )
    })
  })

  describe('set', () => {
    it('returns a well-formed and correct action', () => {
      expect(actions.set('my_arbitrary_key', 'any_old_value')).to.deep.equal(
        {
          type: SET_UI,
          payload: {
            key: 'my_arbitrary_key',
            value: 'any_old_value'
          }
        }
      )
    })
  })

  describe('merge', () => {
    it('returns a well-formed and correct action', () => {
      expect(actions.merge('my_arbitrary_key', { itWill: 'probably be an object' })).to.deep.equal(
        {
          type: MERGE_UI,
          payload: {
            key: 'my_arbitrary_key',
            value: { itWill: 'probably be an object' }
          }
        }
      )
    })
  })

  describe('occludeQuizEntries', () => {
    it('returns a well-formed occludeQuizEntries action', () => {
      const occludeQuizEntriesAction = actions.occludeQuizEntries(true)
      expect(occludeQuizEntriesAction)
        .to.deep.equal({
          type: OCCLUDE_QUIZ_ENTRIES,
          payload: true
        })
    })
  })

  describe('newActiveBankEntry', () => {
    it('returns a well-formed activeBankEntryId change action', () => {
      expect(actions.newActiveBankEntry('132')).to.deep.equal({
        type: ACTIVE_BANK_ENTRY_CHANGE,
        payload: '132'
      })
    })
  })

  describe('newActiveBank', () => {
    it('returns a well-formed activeBankId change action', () => {
      const newActiveBankAction = actions.newActiveBank('123')
      expect(newActiveBankAction).to.deep.equal({
        type: ACTIVE_BANK_CHANGE,
        payload: '123'
      })
    })
  })

  describe('setActiveCalculatorId', () => {
    it('returns a set ui field action', () => {
      const setActiveCalculatorIdAction = actions.setActiveCalculatorId('abc')
      expect(setActiveCalculatorIdAction).to.deep.equal({
        type: SET_UI,
        payload: {
          key: 'activeCalculatorId',
          value: 'abc'
        }
      })
    })
  })
})
