import {
  scrollToItem,
  clearsScrolledComponentKey
} from '../scrolling'

import {
  SCROLL_TO_COMPONENT,
  CLEAR_SCROLLED_COMPONENT
} from '@instructure/quiz-common/lib/constants'

describe('scrolling action creators', () => {
  it('returns a well-formed scroll to item action', () => {
    const scrollToItemAction = scrollToItem('3')

    expect(scrollToItemAction)
      .to.deep.equal({
        type: SCROLL_TO_COMPONENT,
        payload: '3',
        scrollingFocus: true
      })
  })

  it('returns a well-formed scroll to item action without focus', () => {
    const scrollToItemAction = scrollToItem('3', false)

    expect(scrollToItemAction)
      .to.deep.equal({
        type: SCROLL_TO_COMPONENT,
        payload: '3',
        scrollingFocus: false
      })
  })

  it('returns a well-formed clear scrolledComponentKey action', () => {
    const clearsScrolledComponentKeyAction = clearsScrolledComponentKey()

    expect(clearsScrolledComponentKeyAction)
      .to.deep.equal({
        type: CLEAR_SCROLLED_COMPONENT
      })
  })
})
