UNPKG

@amiceli/vitest-cucumber

Version:

vitest tools to use Gherkin feature in unit tests

31 lines (30 loc) 870 B
import { NotAllowedBackgroundStepTypeError } from '../../errors/errors'; import { StepAble } from './Stepable'; import { Step, StepTypes } from './step'; const BackgroundAllowedSteps = [ StepTypes.GIVEN, StepTypes.AND, ]; export class Background extends StepAble { constructor(title = 'Background') { super(title); } getTitle() { return `${this.title}:`; } addStep(step) { if (BackgroundAllowedSteps.includes(step.type)) { super.addStep(step); } else { throw new NotAllowedBackgroundStepTypeError(step.type); } } } export class DefineBackground extends Background { checkIfStepExists(stepType, stepDetails) { const step = new Step(stepType, stepDetails); this.addStep(step); return super.checkIfStepExists(stepType, stepDetails); } }