Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow es6 symbols to be used as action types #295

Merged
merged 2 commits into from
Jul 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/combineReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ActionTypes } from '../createStore';

function getErrorMessage(key: String, action: Action): string {
var actionType = action && action.type;
var actionName = actionType && `"${actionType}"` || 'an action';
var actionName = actionType && `"${actionType.toString()}"` || 'an action';

return (
`Reducer "${key}" returned undefined handling ${actionName}. ` +
Expand Down
17 changes: 17 additions & 0 deletions test/utils/combineReducers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ describe('Utils', () => {
);
});

it('should allow a symbol to be used as an action type', () => {
const increment = Symbol('INCREMENT');

const reducer = combineReducers({
counter(state = 0, action) {
switch (action.type) {
case increment:
return state + 1;
default:
return state;
}
}
});

expect(reducer(0, {type: increment}).counter).toEqual(1);
});

it('should throw an error if a reducer attempts to handle a private action', () => {
expect(() => combineReducers({
counter(state, action) {
Expand Down