import { expect } from 'chai';

import { ADD_ITEM, COMPLETE_ITEM } from '../src/shared/actions/ItemActions';
import itemReducer from '../src/shared/reducers/itemReducer';

describe('reducer', () => {
  describe('addItem', () => {
    it('Returns new correct state', () => {
      const initialState = [
        { text: 'Learn Redux', completed: false }
      ];
      const action = { type: ADD_ITEM, value: 'Learn Node' };
      const newState = itemReducer(initialState, action);
      
      expect(newState.length).to.equal(2);
      expect(newState[1].text).to.equal('Learn Node');
      expect(newState[1].completed).to.equal(false);
      expect(newState).to.not.equal(initialState);
    });
  });
});

@@ -479,15 +479,9 @@
 n);%0A
-      
 %0A
+
     
@@ -623,24 +623,24 @@
 ual(false);%0A
-
       expect
@@ -685,16 +685,1230 @@
 %0A    %7D);
+%0A%0A    it('Initializes state correctly and Returns new correct state', () =%3E %7B%0A      const action = %7B type: ADD_ITEM, value: 'Learn Node' %7D;%0A      const newState = itemReducer(undefined, action);%0A%0A      expect(newState.length).to.equal(1);%0A      expect(newState%5B0%5D.text).to.equal('Learn Node');%0A      expect(newState%5B0%5D.completed).to.equal(false);%0A    %7D);%0A  %7D);%0A%0A  describe('completeItem', () =%3E %7B%0A    it('Correctly sets item as complete', () =%3E %7B%0A      const initialState = %5B%0A        %7B text: 'Learn Redux', completed: false %7D%0A      %5D;%0A      const action = %7B type: COMPLETE_ITEM, id: 0 %7D;%0A      const newState = itemReducer(initialState, action);%0A%0A      expect(newState.length).to.equal(1);%0A      expect(newState%5B0%5D.completed).to.equal(true);%0A      expect(newState%5B0%5D.text).to.equal('Learn Redux');%0A    %7D);%0A  %7D);%0A%0A  describe('Invalid Action', () =%3E %7B%0A    it('Returns initial state if action is not valid', () =%3E %7B%0A      const initialState = %5B%0A        %7B text: 'Learn Redux', completed: false %7D%0A      %5D;%0A      const action = %7B type: %22NOT_REAL_ACTION%22, id: 0 %7D;%0A      const newState = itemReducer(initialState, action);%0A%0A      expect(newState.length).to.equal(1);%0A      expect(newState).to.equal(initialState);%0A    %7D);
 %0A  %7D);%0A%7D

Add more tests for reducer