Skip to content

Commit a76f8c8

Browse files
fix(overmind): fix returning operator execution in tests
1 parent 1bc4774 commit a76f8c8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class Overmind<ThisConfig extends IConfiguration>
293293
const onInitialize = this.createAction(
294294
'onInitialize',
295295
configuration.onInitialize
296-
)
296+
) as any
297297

298298
this.initialized = Promise.resolve(onInitialize(this))
299299
} else {
@@ -371,7 +371,7 @@ export class Overmind<ThisConfig extends IConfiguration>
371371
this.actionReferences.push(action)
372372
const actionFunc = async (value?) => {
373373
if (IS_PRODUCTION || action[IS_OPERATOR]) {
374-
await new Promise((resolve, reject) => {
374+
return new Promise((resolve, reject) => {
375375
const execution = this.createExecution(name, action)
376376
this.eventHub.emit(EventType.ACTION_START, execution)
377377

@@ -451,15 +451,23 @@ export class Overmind<ThisConfig extends IConfiguration>
451451
result: undefined,
452452
})
453453
this.eventHub.emit(EventType.ACTION_END, execution)
454-
await result
454+
455+
if (result) {
456+
await result
457+
}
458+
455459
return this.options.testMode && execution
456460
}
457461
}
458462

459463
if (this.options.testMode) {
460464
const actionCallback = this.options.testMode.actionCallback
461465

462-
return (value?) => (actionFunc as any)(value).then(actionCallback)
466+
return async (value?) => {
467+
const result = await actionFunc(value)
468+
469+
return actionCallback(result)
470+
}
463471
}
464472

465473
return actionFunc

packages/node_modules/proxy-state-tree/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ export class ProxyStateTree<T extends object> implements IProxyStateTree<T> {
163163
}
164164

165165
if (!changes.mutations.length && !changes.objectChanges.size) {
166-
return
166+
return {
167+
mutations: [],
168+
flushId: null,
169+
}
167170
}
168171

169172
const paths = new Set()

0 commit comments

Comments
 (0)