Skip to content

Commit 02700fd

Browse files
fix(overmind): fix passing args to mocked effects
1 parent 39683ad commit 02700fd

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ export function createOvermindMock<Config extends IConfiguration>(
135135
} has not been mocked`
136136
)
137137
}
138-
return mockedEffect[effect.method]({
139-
path: effect.name + '.' + effect.method,
140-
args: effect.args,
141-
})
138+
return mockedEffect[effect.method](...effect.args)
142139
},
143140
actionCallback: (execution) => {
144141
return execution.flush().mutations

packages/node_modules/overmind/src/mock.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ describe('Mock', () => {
99
foo: 'bar',
1010
}
1111
const test: Action = ({ state, effects }) => {
12-
state.foo = effects.effect()
12+
state.foo = effects.effect('bar2')
1313
}
1414
const actions = { test }
15-
const effect = () => 'bar2'
15+
const effect = (arg: string) => arg
1616
const effects = { effect }
1717
const config = {
1818
state,
@@ -25,8 +25,8 @@ describe('Mock', () => {
2525
interface Action<Input = void> extends IAction<Config, Input> {}
2626

2727
const overmind = createOvermindMock(config, {
28-
effect() {
29-
return 'bar3'
28+
effect(arg) {
29+
return arg + '!!!'
3030
},
3131
})
3232

@@ -36,7 +36,7 @@ describe('Mock', () => {
3636
{
3737
method: 'set',
3838
path: 'foo',
39-
args: ['bar3'],
39+
args: ['bar2!!!'],
4040
},
4141
])
4242
})

0 commit comments

Comments
 (0)