import { Map } from 'immutable'
import outcomesReducer from '../outcomes'
import {
  setContextUuid,
  setOutcomesEndpoint,
  setOutcomesToken
} from '../../actions/outcomes'

describe('outcomes reducer', () => {
  it('properly sets context uuid', () => {
    const uuid = 'alphabeta'
    const initialState = Map()

    const action = setContextUuid(uuid)
    const nextState = outcomesReducer(initialState, action)

    expect(nextState.get('contextUuid')).to.equal(uuid)
  })

  it('properly sets outcomes endpoint', () => {
    const endpoint = 'http://outcomes.test'
    const initialState = Map()

    const action = setOutcomesEndpoint(endpoint)
    const nextState = outcomesReducer(initialState, action)

    expect(nextState.get('outcomesEndpoint')).to.equal(endpoint)
  })

  it('properly sets outcomes token', () => {
    const token = 'alphabetacharlie'
    const initialState = Map()

    const action = setOutcomesToken(token)
    const nextState = outcomesReducer(initialState, action)

    expect(nextState.get('outcomesToken')).to.equal(token)
  })
})
