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

Reducers can occasionally receive actions without a type #44

Merged
merged 10 commits into from
Feb 15, 2018
19 changes: 19 additions & 0 deletions src/actions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { isNgrxFormsAction } from './actions';

describe(isNgrxFormsAction.name, () => {
it('should return true if type is ngrx/forms/', () => {
expect(isNgrxFormsAction({ type: 'ngrx/forms/' })).toBe(true);
});

it('should return true if type startsWith ngrx/forms/', () => {
expect(isNgrxFormsAction({ type: 'ngrx/forms/test' })).toBe(true);
});

it('should return false if type does not have ngrx/forms/', () => {
expect(isNgrxFormsAction({ type: 'some-type' })).toBe(false);
});

it('should return false if type is missing', () => {
expect(isNgrxFormsAction({} as any)).toBe(false);
});
});
2 changes: 1 addition & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,5 +334,5 @@ export type Actions<TValue> =
;

export function isNgrxFormsAction(action: Action) {
return action.type.startsWith('ngrx/forms/');
return !!action.type && action.type.startsWith('ngrx/forms/');
}