@amiceli/vitest-cucumber
Version:
vitest tools to use Gherkin feature in unit tests
22 lines (21 loc) • 805 B
JavaScript
import { SyntaxKind } from 'ts-morph';
import { BaseAst } from './BaseAst';
export class StepableAst extends BaseAst {
stepableParent;
stepableParentFunction;
forRule;
constructor(options) {
super(options);
this.stepableParent = options.stepableParent;
this.stepableParentFunction = options.stepableParentFunction;
this.forRule = options.forRule === true;
}
updateStepableArguments(stepable, stepableArrowFunction) {
const stepTypes = stepable.steps.map((step) => step.type);
const stepTypesArg = `{ ${stepTypes.join(',')} }`;
const currentArg = stepableArrowFunction.getFirstDescendantByKind(SyntaxKind.ObjectBindingPattern);
if (currentArg) {
currentArg.replaceWithText(stepTypesArg);
}
}
}