UNPKG

harmonyc

Version:

Harmony Code - model-driven BDD for Vitest

16 lines (15 loc) 554 B
import { Label, Section, Step } from "../../model/model.js"; export function autoLabel(s) { const forks = s.children.filter((c, i) => c.isFork || i === 0); if (forks.length > 1) { forks .filter((c) => c instanceof Step) .forEach((c) => { const label = c.action.toSingleLineString(); const autoSection = new Section(new Label(label), [], c.isFork); c.replaceWith(autoSection); autoSection.addChild(c); }); } s.children.forEach((c) => autoLabel(c)); }