import { expect } from 'chai'

import {
  receiveFile,
  clearAltText,
  clearFiles,
  uploadStatus,
  setAltText
} from '../upload'

import {
  FILE_RECEIVED,
  CLEAR_ALT_TEXT,
  CLEAR_FILES,
  FILE_UPLOAD_STATUS,
  SET_ALT_TEXT
} from '@instructure/quiz-common/lib/constants'

describe('upload action creators', () => {
  it('returns a well-formed receiveFile action', () => {
    const file = 'file'
    const receiveFileObj = receiveFile(file)
    expect(receiveFileObj).to.deep.equal({type: FILE_RECEIVED, payload: {file}})
  })

  it('returns a well-formed clearAltText action', () => {
    const clearAltTextObj = clearAltText()
    expect(clearAltTextObj).to.deep.equal({type: CLEAR_ALT_TEXT})
  })

  it('returns a well-formed clearFiles action', () => {
    const clearFilesObj = clearFiles()
    expect(clearFilesObj).to.deep.equal({type: CLEAR_FILES})
  })

  it('returns a well-formed uploadStatus action', () => {
    const uploadStatusObj = uploadStatus('ASTATUS')
    expect(uploadStatusObj).to.deep.eq({type: FILE_UPLOAD_STATUS, payload: {status: 'ASTATUS'}})
  })

  it('returns a well-formed setAltText action', () => {
    const setAltTextObj = setAltText('some alt text')
    expect(setAltTextObj).to.deep.eq({type: SET_ALT_TEXT, payload: {altText: 'some alt text'}})
  })
})
