import expect from 'expect';
import rewire from 'rewire';
import * as constants from '../HomePage.constants';

let homeReducer = rewire('../HomePage.reducer');
const initialState = homeReducer.__get__('initialState');
homeReducer = homeReducer.default;

// Test Reducer
describe('defaultReducer', () => {
  // Test that the initial state is returning correctly
  it('should return the initial state', () => {
    expect(homeReducer(undefined, {})).toEqual(initialState);
  });

  // Test that it handles changing the owner correctly
  it('should handle the CHANGE_OWNER_NAME action', () => {
    const name = 'samsmith';

    expect(
      homeReducer({}, {
        type: constants.CHANGE_OWNER_NAME,
        name
      })
    ).toEqual({
      ownerName: name
    });
  });

  // Test that it handles changing the project name correctly
  it('should handle the CHANGE_PROJECT_NAME action', () => {
    const name = 'Webapplication Boilerplate';

    expect(
      homeReducer({}, {
        type: constants.CHANGE_PROJECT_NAME,
        name
      })
    ).toEqual({
      projectName: name
    });
  });
});

@@ -107,13 +107,69 @@
 s';%0A
-%0Alet 
+import homeReducer from '../HomePage.reducer';%0A%0Aconst rewired
 home
@@ -230,16 +230,23 @@
 State = 
+rewired
 homeRedu
@@ -277,43 +277,8 @@
 e');
-%0AhomeReducer = homeReducer.default;
 %0A%0A//

Fix HomePage Reducer test