Skip to content

Commit

Permalink
Merge 761b729 into 8ddeae4
Browse files Browse the repository at this point in the history
  • Loading branch information
RomkeVdMeulen committed Oct 6, 2022
2 parents 8ddeae4 + 761b729 commit 9e00cb8
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/rules/indentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as gherkinUtils from "./utils/gherkin";
import { Feature, ResultError, Step, Tag } from "../types";
import { Examples, Feature, ResultError, Scenario, Step, Tag } from "../types";
import chalk from "chalk";

const _ = require("lodash");
Expand Down Expand Up @@ -70,27 +70,41 @@ export function run(feature: Feature, unused, configuration): ResultError[] {
});
}

function testScenario(scenario: Scenario) {
test(scenario.location, "Scenario");
testTags(scenario.tags, "scenario tag");
scenario.steps?.forEach(testStep);
if (scenario.examples) {
testExamples(scenario.examples);
}
}

function testExamples(examples: Examples[]) {
examples.forEach(example => {
test(example.location, "Examples");
if (example.tableHeader) {
test(example.tableHeader.location, "example");
example.tableBody?.forEach(row => {
test(row.location, "example");
});
}
});
}

test(feature.location, "Feature");
testTags(feature.tags, "feature tag");
feature.children?.forEach(child => {
if (child.rule) {
test(child.rule.location, "Rule");
if (child.rule.children) {
child.rule.children.forEach(ruleChild =>
ruleChild.scenario?.examples && testExamples(ruleChild.scenario!.examples));
}
} else if (child.background) {
test(child.background.location, "Background");
child.background.steps?.forEach(testStep);
} else {
test(child.scenario?.location, "Scenario");
testTags(child.scenario?.tags, "scenario tag");
child.scenario?.steps?.forEach(testStep);
child.scenario?.examples?.forEach(examples => {
test(examples.location, "Examples");
if (examples.tableHeader) {
test(examples.tableHeader.location, "example");
examples.tableBody?.forEach(row => {
test(row.location, "example");
});
}
});
} else if (child.scenario) {
testScenario(child.scenario);
}
});
return errors;
Expand Down

0 comments on commit 9e00cb8

Please sign in to comment.