Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
actual = args
}
const middleware = sagaMiddleware()
try {
middleware.run(function*() {})
} catch (e) {
// middleware.run must throw an Error when executed before the middleware is connected to a Store
expect(e instanceof Error).toBe(true)
}
createStore(() => {}, applyMiddleware(middleware))
const task = middleware.run(saga, 'argument') // middleware.run must return a Task Object
expect(is.task(task)).toBe(true)
const expected = ['argument'] // middleware must run the Saga and provides it with the given arguments
expect(actual).toEqual(expected)
})
function resolveEffect(effectId, result) {
const effect = manager.get(effectId);
if (is.task(result)) {
result.toPromise().then(
taskResult => {
if (result.isCancelled()) {
cancelEffect(effectId);
} else {
resolveEffect(effectId, taskResult);
}
},
taskError => rejectEffect(effectId, taskError)
);
} else {
computeEffectDur(effect);
effect.status = RESOLVED;
effect.result = result;
if (isRaceEffect(effect.effect)) {
setRaceWinner(effectId, result);
function resolveEffect(effectId, result) {
const effect = manager.get(effectId)
if (is.task(result)) {
result.toPromise().then(
taskResult => {
if (result.isCancelled()) {
cancelEffect(effectId)
} else {
resolveEffect(effectId, taskResult)
}
},
taskError => rejectEffect(effectId, taskError),
)
} else {
computeEffectDur(effect)
effect.status = RESOLVED
effect.result = result
if (isRaceEffect(effect.effect)) {
setRaceWinner(effectId, result)