import { fromJS, Map } from 'immutable'
import {
  HOVER_POSITION
} from '@instructure/quiz-common/lib/constants'

import dragAndDropReducer from '../dragAndDrop'

describe('drag and drop reducer', () => {
  const nextStateEquals = (nextState, stateExpectations) => {
    const nextStateImmutable = fromJS(nextState)
    const stateExpectationsImmutable = fromJS(stateExpectations)
    expect(nextStateImmutable.equals(stateExpectationsImmutable)).to.be.true()
  }

  it('should be able to set position', () => {
    const initialState = Map()
    const action = {
      type: HOVER_POSITION,
      payload: {
        position: 2,
        aboveHalf: true,
        fromAbove: false
      }
    }

    nextStateEquals(
      dragAndDropReducer(initialState, action),
      {
        position: 2,
        aboveHalf: true,
        fromAbove: false
      }
    )
  })
})
