diff --git a/src/__tests__/__snapshots__/create-handler-map.dts.spec.ts.snap b/src/__tests__/__snapshots__/create-handler-map.dts.spec.ts.snap index 6edab3a..0e68e07 100644 --- a/src/__tests__/__snapshots__/create-handler-map.dts.spec.ts.snap +++ b/src/__tests__/__snapshots__/create-handler-map.dts.spec.ts.snap @@ -4,4 +4,4 @@ exports[`createHandlerMap handle([increment, increase], (state: number) => state exports[`createHandlerMap handle(increment, (state: number) => state + 1) (type) should match snapshot 1`] = `"HandlerMap"`; -exports[`createHandlerMap handle.default((state: number) => state + 1) (type) should match snapshot 1`] = `"{ default: Handler; }"`; +exports[`createHandlerMap handle.others((state: number) => state + 1) (type) should match snapshot 1`] = `"{ default: Handler; }"`; diff --git a/src/__tests__/create-handler-map.dts.spec.ts b/src/__tests__/create-handler-map.dts.spec.ts index cad8dbd..8a54fff 100644 --- a/src/__tests__/create-handler-map.dts.spec.ts +++ b/src/__tests__/create-handler-map.dts.spec.ts @@ -13,4 +13,4 @@ handle(increment, (state: number) => state + 1) handle([increment, increase], (state: number) => state + 1) // @dts-jest:pass:snap -handle.default((state: number) => state + 1) +handle.others((state: number) => state + 1) diff --git a/src/__tests__/create-handler-map.spec.ts b/src/__tests__/create-handler-map.spec.ts index 0097766..2dcaef7 100644 --- a/src/__tests__/create-handler-map.spec.ts +++ b/src/__tests__/create-handler-map.spec.ts @@ -17,8 +17,8 @@ describe('createHandlerMap', () => { ).toMatchSnapshot() }) - it('should put the handler by "default" key', () => { + it('should put the "others" handler by "default" key', () => { const reducer = (state: number) => state + 1 - expect(handle.default(reducer)).toEqual({ default: reducer }); + expect(handle.others(reducer)).toEqual({ default: reducer }); }) }) diff --git a/src/__tests__/create-reducer.spec.ts b/src/__tests__/create-reducer.spec.ts index 05485f6..66174c4 100644 --- a/src/__tests__/create-reducer.spec.ts +++ b/src/__tests__/create-reducer.spec.ts @@ -62,18 +62,18 @@ describe('createReducer', () => { const defaultCounterState = 0 const handleReset = jest.fn(() => defaultCounterState); - const handleDefault = jest.fn((state: number, { payload }: Action) => ( + const handleOthers = jest.fn((state: number, { payload }: Action) => ( payload % 2 === 0 ? state + 1 : state )) const evenNumbersCounterReducer = createReducer(defaultCounterState, handleAction => [ handleAction(resetCounter, handleReset), - handleAction.default(handleDefault) + handleAction.others(handleOthers) ]) beforeEach(() => { handleReset.mockReset() - handleDefault.mockReset() + handleOthers.mockReset() }) it('should initiate with default state when state is undefined', () => { @@ -86,14 +86,14 @@ describe('createReducer', () => { expect(evenNumbersCounterReducer(5, resetCounter())).toBe(handleReset()) expect(handleReset).toBeCalledTimes(2) - expect(handleDefault).not.toBeCalled() + expect(handleOthers).not.toBeCalled() }) it('should calls the default handler when there is no proper handler', () => { const action = drawNumber(6) expect(evenNumbersCounterReducer(defaultCounterState, action)).toBe( - handleDefault(defaultCounterState, action) + handleOthers(defaultCounterState, action) ) }) }) diff --git a/src/create-handler-map.ts b/src/create-handler-map.ts index e153e7b..0f124b6 100644 --- a/src/create-handler-map.ts +++ b/src/create-handler-map.ts @@ -19,7 +19,7 @@ export type InferNextStateFromHandlerMap< type InferActionFromCreator = TActionCreator extends (...args: any[]) => infer T ? T : never -type CreateDefaultHandler = < +type CreateOthersHandler = < TActionCreator extends ActionCreator, TNextState extends TPrevState, TAction extends AnyAction = InferActionFromCreator @@ -37,7 +37,7 @@ type CreateCustomHandlerMap = < ) => HandlerMap export type CreateHandlerMap = CreateCustomHandlerMap & { - default: CreateDefaultHandler + others: CreateOthersHandler } /** @@ -68,7 +68,7 @@ export const createHandlerMap = Object.assign( }, {} as any) }, { - default: , + others: , TPrevState, TNextState extends TPrevState, TAction extends AnyAction = InferActionFromCreator