Skip to content

Commit

Permalink
dnd reducer full unit tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno12mota committed Jan 23, 2017
1 parent 4c61282 commit 829defc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions lib/shared/reducers/__tests__/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('DND Reducer', () => {
id: 5
};

const theState = defaultState;
const theState = Object.assign({}, defaultState);
// delete the key dropInfo of theState to assign it a new value
delete theState.dropInfo;
theState.dropInfo = {};
Expand All @@ -48,7 +48,21 @@ describe('DND Reducer', () => {
expect(dndReducer(theState, action).dropInfo).toBeFalsy();
});

it('should handle OUT_DROPPABLE with no dropInfo', () => {
const action = {
type: actionTypes.outDroppable,
id: 5
};

const theState = Object.assign({}, defaultState);

expect(dndReducer(theState)).toBe(theState);
expect(dndReducer(theState, action)).toBe(theState);
});

it('should handle STOP_DRAGGING', () => {
expect(dndReducer(defaultState, {})).toBe(defaultState);
expect(dndReducer(defaultState, {
type: actionTypes.stopDragging
})).toBe(defaultState);
});
});
2 changes: 1 addition & 1 deletion lib/shared/reducers/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function dndReducer (state = defaultState, action = {}) {
}
return state;
case actionTypes.stopDragging:
return Object.assign({}, defaultState);
return defaultState;
default:
return state;
}
Expand Down

0 comments on commit 829defc

Please sign in to comment.