Skip to content

Commit

Permalink
test(store): fix strictImmutability tests passing by default
Browse files Browse the repository at this point in the history
'NgRx' actions were passing tests by default as no case handled them in
the reducer. Adding cases to handle 'NgRx' actions exposed a futher
error in the tests. 'should not throw for NgRx actions' test was testing
and failing against an Unserializable state. The library allows NgRx
actions where the action is Unserializable so the 'should not throw for
NgRx actions' test was moved from State Serialization to Action
Serialization.
  • Loading branch information
donohoea committed Jul 5, 2021
1 parent abb0589 commit af78b68
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions modules/store/spec/runtime_checks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ describe('Runtime checks:', () => {
flush();
}).not.toThrow();
}));

it('should not throw for NgRx actions', fakeAsync(() => {
const store = setupStore({ strictStateSerializability: true });

expect(() => {
store.dispatch(makeNgrxAction(invalidAction()));
flush();
}).not.toThrow();
}));
});

describe('Action Serialization:', () => {
Expand All @@ -172,6 +163,15 @@ describe('Runtime checks:', () => {
flush();
}).not.toThrow();
}));

it('should not throw for NgRx actions', fakeAsync(() => {
const store = setupStore({ strictActionSerializability: true });

expect(() => {
store.dispatch(makeNgrxAction(invalidAction()));
flush();
}).not.toThrow();
}));
});

describe('State Mutations', () => {
Expand Down Expand Up @@ -339,6 +339,12 @@ function reducerWithBugs(state: any = {}, action: any) {
invalid: new Date(),
};

case '@ngrx ' + ErrorTypes.UnserializableState:
return {
invalidSerializationState: true,
invalid: new Date(),
};

case ErrorTypes.UnserializableAction: {
return {
invalidSerializationAction: true,
Expand All @@ -351,6 +357,12 @@ function reducerWithBugs(state: any = {}, action: any) {
invalidMutationAction: true,
};
}
case '@ngrx ' + ErrorTypes.MutateAction: {
action.foo = 'foo';
return {
invalidMutationAction: true,
};
}

case ErrorTypes.MutateState: {
state.invalidMutationState = true;
Expand Down

0 comments on commit af78b68

Please sign in to comment.