setDefaultMutation returns the right type
This commit is contained in:
parent
90e90779e1
commit
2f687cfda3
@ -210,7 +210,7 @@ export default class Updux<D extends DuxConfig> {
|
|||||||
setDefaultMutation(
|
setDefaultMutation(
|
||||||
mutation: Mutation<any, DuxState<D>>,
|
mutation: Mutation<any, DuxState<D>>,
|
||||||
terminal?: boolean,
|
terminal?: boolean,
|
||||||
);
|
): Updux<D>;
|
||||||
setDefaultMutation(mutation, terminal = false) {
|
setDefaultMutation(mutation, terminal = false) {
|
||||||
this.#defaultMutation = { terminal, mutation };
|
this.#defaultMutation = { terminal, mutation };
|
||||||
return this;
|
return this;
|
||||||
|
@ -98,3 +98,15 @@ test('actionType as string', () => {
|
|||||||
dux.addMutation('unknown', () => (x) => x);
|
dux.addMutation('unknown', () => (x) => x);
|
||||||
}).toThrow();
|
}).toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('setDefaultMutation return value', () => {
|
||||||
|
const dux = new Updux({
|
||||||
|
initialState: 13,
|
||||||
|
});
|
||||||
|
|
||||||
|
let withDM = dux.setDefaultMutation(() => (state) => state);
|
||||||
|
|
||||||
|
expect(withDM).toEqual(dux);
|
||||||
|
|
||||||
|
expectTypeOf(withDM.initialState).toBeNumber();
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user