diff --git a/modules/store/spec/reducer_creator.spec.ts b/modules/store/spec/reducer_creator.spec.ts index 1f361c8141..20f852b6a6 100644 --- a/modules/store/spec/reducer_creator.spec.ts +++ b/modules/store/spec/reducer_creator.spec.ts @@ -11,6 +11,13 @@ describe('classes/reducer', function (): void { describe('base', () => { const bar = createAction('[foobar] BAR', props<{ bar: number }>()); const foo = createAction('[foobar] FOO', props<{ foo: number }>()); + const withDefaultParameter = createAction( + '[foobar] withDefaultParameter', + (foo: number = 4, bar: number = 7) => ({ + foo, + bar, + }) + ); describe('on', () => { it('should support reducers with multiple actions', () => { @@ -32,7 +39,8 @@ describe('classes/reducer', function (): void { const fooBarReducer = createReducer( {} as State, on(foo, (state, { foo }) => ({ ...state, foo })), - on(bar, (state, { bar }) => ({ ...state, bar })) + on(bar, (state, { bar }) => ({ ...state, bar })), + on(withDefaultParameter, (_state, { type: _, ...payload }) => payload) ); expect(typeof fooBarReducer).toEqual('function'); @@ -45,6 +53,9 @@ describe('classes/reducer', function (): void { state = fooBarReducer(state, bar({ bar: 54 })); expect(state).toEqual({ foo: 42, bar: 54 }); + + state = fooBarReducer(state, withDefaultParameter()); + expect(state).toEqual({ foo: 4, bar: 7 }); }); it('should create a primitive reducer', () => {