mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
public commit
This commit is contained in:
24
app/__test__/flows/inc/back.ts
Normal file
24
app/__test__/flows/inc/back.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Condition, Flow } from "../../../src/flows";
|
||||
import { getNamedTask } from "./helper";
|
||||
|
||||
const first = getNamedTask("first");
|
||||
const second = getNamedTask("second");
|
||||
const fourth = getNamedTask("fourth");
|
||||
|
||||
let thirdRuns = 0;
|
||||
const third = getNamedTask("third", async () => {
|
||||
thirdRuns++;
|
||||
if (thirdRuns === 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new Error("Third failed");
|
||||
});
|
||||
|
||||
const back = new Flow("back", [first, second, third, fourth]);
|
||||
back.task(first).asInputFor(second);
|
||||
back.task(second).asInputFor(third);
|
||||
back.task(third).asInputFor(second, Condition.error(), 2);
|
||||
back.task(third).asInputFor(fourth, Condition.success());
|
||||
|
||||
export { back };
|
||||
Reference in New Issue
Block a user