Skip to content

Commit

Permalink
chore: drop comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Nov 22, 2024
1 parent ba8e5cd commit 989b312
Showing 1 changed file with 1 addition and 190 deletions.
191 changes: 1 addition & 190 deletions src/generate/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,46 +256,7 @@ export class TestFile {
}

/**
* Generate test from Examples row of Scenario Outline
*/
// private getOutlineTest(
// scenario: Scenario,
// examples: Examples,
// exampleRow: TableRow,
// title: string,
// parent: TestNode,
// ) {
// const node = new TestNode({ name: title, tags: examples.tags }, parent);
// if (this.isSkippedByTagsExpression(node)) return [];
// const pickle = this.bddMetaBuilder.registerTest(node, exampleRow.id);
// if (this.isSkippedBySpecialTag(node)) {
// return this.formatter.test(node, new Set(), pickle.location.line, []);
// }
// const { fixtures, lines, hasMissingSteps } = this.getSteps(scenario, node.tags, exampleRow.id);
// this.handleMissingStepsInScenario(hasMissingSteps, node);
// this.hooks.registerHooksForTest(node);
// return this.formatter.test(node, fixtures, pickle.location.line, lines);
// }

/**
* Generate test from Scenario
*/
// private getTestOld(scenario: Scenario, parent: TestNode) {
// const node = new TestNode(scenario, parent);
// if (this.isSkippedByTagsExpression(node)) return [];
// const pickle = this.bddMetaBuilder.registerTest(node, scenario.id);
// if (this.isSkippedBySpecialTag(node)) {
// return this.formatter.test(node, new Set(), pickle.location.line, []);
// }
// const { fixtures, lines, hasMissingSteps } = this.getSteps(scenario, node.tags);
// this.handleMissingStepsInScenario(hasMissingSteps, node);
// this.hooks.registerHooksForTest(node);
// return this.formatter.test(node, fixtures, pickle.location.line, lines);
// }

/**
* NEW way of getting test - by pickle
* Universal for Scenario and Scenario Outline
* Render test for Scenario or Scenario Outline.
*/
private renderTest(
pickle: PickleWithLocation,
Expand Down Expand Up @@ -331,156 +292,6 @@ export class TestFile {
return pickles[0];
}

/**
* Generate test steps
*/
// private getSteps(scenario: Scenario | Background, tags?: string[], outlineExampleRowId?: string) {
// const testFixtureNames = new Set<string>();
// const decoratorSteps = new DecoratorSteps({
// statefulPoms: this.config.statefulPoms,
// featureUri: this.featureUri,
// testTitle: scenario.name || 'Background',
// testFixtureNames,
// testTags: tags,
// });

// const stepToKeywordType = mapStepsToKeywordTypes(scenario.steps, this.language);
// let hasMissingSteps = false;

// // todo: refactor internal fn, move to a separate class.
// // The problem - it is highly coupled with the testFile class,
// // need to pass many params: config, language, featureUri, i18nKeywordsMap, gherkinDocument, etc...
// // eslint-disable-next-line max-statements
// const lines = scenario.steps.map((step, index) => {
// const keywordType = stepToKeywordType.get(step)!;
// const keywordEng = this.getStepEnglishKeyword(step);
// testFixtureNames.add(keywordEng);
// this.bddMetaBuilder.registerStep(step, keywordType);
// // pickleStep contains step text with inserted example values and argument
// const pickleStep = this.findPickleStep(step, outlineExampleRowId);
// const matchedDefinition = this.findMatchedDefinition(keywordType, step, pickleStep, tags);
// if (!matchedDefinition) {
// hasMissingSteps = true;
// return this.handleMissingStep(keywordEng, keywordType, pickleStep, step);
// }

// this.usedStepDefinitions.add(matchedDefinition.definition);

// if (matchedDefinition.definition.isDecorator()) {
// decoratorSteps.push({
// index,
// keywordEng,
// pickleStep,
// pomNode: matchedDefinition.definition.pomNode,
// });

// // for decorator steps, line and fixtureNames are filled later in second pass
// return '';
// }

// const stepFixtureNames = this.getStepFixtureNames(matchedDefinition);
// stepFixtureNames.forEach((fixtureName) => testFixtureNames.add(fixtureName));

// return this.formatter.step(
// keywordEng,
// pickleStep.text,
// pickleStep.argument,
// stepFixtureNames,
// );
// });

// // fill decorator step slots in second pass (to guess fixtures)
// // TODO: for background steps we can delay resolving fixtures
// // until all scenarios steps are processed. After that we know all used fixtures,
// // and can guess background fixtures more precisely.
// // But for statefulPoms=false (that is default) it is not very important.
// decoratorSteps.resolveFixtureNames();
// decoratorSteps.forEach(({ index, keywordEng, pickleStep, fixtureName }) => {
// testFixtureNames.add(fixtureName);
// this.usedDecoratorFixtures.add(fixtureName);
// const stepFixtureNames = [fixtureName];
// lines[index] = this.formatter.step(
// keywordEng,
// pickleStep.text,
// pickleStep.argument,
// stepFixtureNames,
// );
// });

// return { fixtures: testFixtureNames, lines, hasMissingSteps };
// }

// private findMatchedDefinition(
// keywordType: KeywordType,
// scenarioStep: Step,
// pickleStep: PickleStep,
// tags?: string[],
// ) {
// const matchedDefinitions = this.stepFinder.findDefinitions(keywordType, pickleStep.text, tags);

// if (matchedDefinitions.length > 1) {
// const stepTextWithKeyword = getStepTextWithKeyword(scenarioStep.keyword, pickleStep.text);
// const stepLocation = `${this.featureUri}:${stringifyLocation(scenarioStep.location)}`;
// // todo: maybe not exit and collect all duplicates?
// exit(formatDuplicateStepsMessage(matchedDefinitions, stepTextWithKeyword, stepLocation));
// }

// return matchedDefinitions[0];
// }

// private handleMissingStep(
// keywordEng: StepFixtureName,
// keywordType: KeywordType,
// pickleStep: PickleStep,
// step: Step,
// ) {
// const { line, column } = step.location;
// this.missingSteps.push({
// location: { uri: this.featureUri, line, column },
// textWithKeyword: getStepTextWithKeyword(step.keyword, pickleStep.text),
// keywordType,
// pickleStep,
// });
// return this.formatter.missingStep(keywordEng, pickleStep.text);
// }

// private findPickleStep(step: Step, exampleRowId?: string) {
// let pickleSteps = this.gherkinDocumentQuery.getPickleSteps(step.id);
// if (exampleRowId) {
// pickleSteps = pickleSteps.filter((pickleStep) =>
// pickleStep.astNodeIds.includes(exampleRowId),
// );
// throwIf(pickleSteps.length > 1, `Several pickle steps found for scenario step: ${step.text}`);
// }
// throwIf(pickleSteps.length === 0, `Pickle step not found for scenario step: ${step.text}`);
// // several pickle steps should be found only for bg steps
// // it's ok to take the first for bg
// return pickleSteps[0];
// }

// private getStepEnglishKeyword(step: Step) {
// const keywordLocal = step.keyword.trim();
// let keywordEng;
// if (keywordLocal === '*') {
// keywordEng = 'And';
// } else if (this.i18nKeywordsMap) {
// keywordEng = this.i18nKeywordsMap.get(keywordLocal);
// } else {
// keywordEng = keywordLocal;
// }
// if (!keywordEng) throw new Error(`Keyword not found: ${keywordLocal}`);
// return keywordEng as StepFixtureName;
// }

// private getStepFixtureNames({ definition }: MatchedStepDefinition) {
// // for cucumber-style there is no fixtures arg,
// // fixtures are accessible via this.world
// if (definition.isCucumberStyle()) return [];

// return fixtureParameterNames(definition.fn) // prettier-ignore
// .filter((name) => !isBddAutoInjectFixture(name));
// }

private isSkippedByTagsExpression(tags: string[]) {
// see: https://github.com/cucumber/tag-expressions/tree/main/javascript
const { tagsExpression } = this.options;
Expand Down

0 comments on commit 989b312

Please sign in to comment.