import { Set } from 'immutable'

import featuresReducer from '../features'

import {
  addFeatures,
  removeFeatures
} from '../../actions/features'

describe('features reducer', () => {
  it('properly adds features to the set', () => {
    const initialState = Set()

    const exampleFeature = 'feat2'
    const featuresList = ['feat1', exampleFeature, 'feat3']
    const action = addFeatures(featuresList)
    const nextState = featuresReducer(initialState, action)

    expect(nextState.includes(exampleFeature)).to.be.true()
  })

  it('properly removes features from the set', () => {
    const initialState = Set(['feat1', 'feat2', 'feat3'])

    const featuresToRemove = ['feat2', 'feat3']
    const action = removeFeatures(featuresToRemove)
    const nextState = featuresReducer(initialState, action)

    expect(nextState.includes('feat2')).to.be.false()
    expect(nextState.includes('feat1')).to.be.true()
  })
})
