Minimal reproduction of the bug/regression with instructions:
interface MyFeatureState {
myProp?: string;
}
const selectMyFeature = createFeatureSelector<MyFeatureState>('my-feature');
const selectMyProp = createSelector(selectMyFeature,
(state: MyFeatureState) => state.myProp);
TestBed.configureTestingModule({
providers: [provideMockStore()],
}).compileComponents();
const store: MockStore<any> = TestBed.get(Store);
const mockSelector = store.overrideSelector(selectMyProp, undefined);
mockSelector.setResult(undefined);
store.refreshState();
store.select(selectMyProp).subscribe(val => expect(val).toBe(undefined))
Expected behavior:
User should be able to override selector result with undefined too, at this moment undefined value is indicating that the selector result is not overwritten, thus mockstore will try to run all the selector logic.
This would be useful in case of a deep state contains an optional value and the user do not want to define the whole state tree in the parameter of the provideMockStore method. As a workaround setResult can be called with null as any, but projects can ban null keyword via a tslint rule, thus it might requires additional lint ignore comment too.
NgRx should use a different variable for indicating is the selector value overwritten.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx: 8.4.0
I would be willing to submit a PR to fix this issue
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
Minimal reproduction of the bug/regression with instructions:
Expected behavior:
User should be able to override selector result with
undefinedtoo, at this momentundefinedvalue is indicating that the selector result is not overwritten, thus mockstore will try to run all the selector logic.This would be useful in case of a deep state contains an optional value and the user do not want to define the whole state tree in the parameter of the
provideMockStoremethod. As a workaroundsetResultcan be called withnull as any, but projects can ban null keyword via a tslint rule, thus it might requires additional lint ignore comment too.NgRx should use a different variable for indicating is the selector value overwritten.
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
NgRx: 8.4.0
I would be willing to submit a PR to fix this issue
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No