import { Arr } from '@ephox/katamari'; import { Chain } from './Chain'; import { sequence } from './GeneralSteps'; import { Step } from './Step'; const generateLogMsg = (testId: string, description: string): string => // AP-147 Format: 'TestCase-- ' `TestCase-${testId}: ${description}`; const step = (testId: string, description: string, f: Step): Step => Step.label(generateLogMsg(testId, description), f); const steps = (testId: string, description: string, fs: Step[]): Step[] => Arr.map(fs, (f, i) => step(testId, description + ' (' + i + ')', f)); const stepsAsStep = (testId: string, description: string, fs: Step[]): Step => sequence(steps(testId, description, fs)); const chain = (testId: string, description: string, c: Chain): Chain => Chain.label(generateLogMsg(testId, description), c); const chains = (testId: string, description: string, cs: Chain[]): Chain[] => Arr.map(cs, (c, i) => chain(testId, description + ' (' + i + ')', c)); const chainsAsChain = (testId: string, description: string, cs: Chain[]): Chain => Chain.fromChains(chains(testId, description, cs)); const chainsAsStep = (testId: string, description: string, cs: Chain[]): Step => Chain.asStep({}, chains(testId, description, cs)); export { step, steps, stepsAsStep, chain, chains, chainsAsChain, chainsAsStep };