Skip to content

Commit

Permalink
Test examples below rules, not scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
RomkeSandwave committed Oct 6, 2022
1 parent 8a061a0 commit 761b729
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 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, Scenario, Step, Tag } from "../types";
import { Examples, Feature, ResultError, Scenario, Step, Tag } from "../types";
import chalk from "chalk";

const _ = require("lodash");
Expand Down Expand Up @@ -74,11 +74,17 @@ export function run(feature: Feature, unused, configuration): ResultError[] {
test(scenario.location, "Scenario");
testTags(scenario.tags, "scenario tag");
scenario.steps?.forEach(testStep);
scenario.examples?.forEach(examples => {
test(examples.location, "Examples");
if (examples.tableHeader) {
test(examples.tableHeader.location, "example");
examples.tableBody?.forEach(row => {
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");
});
}
Expand All @@ -90,7 +96,10 @@ export function run(feature: Feature, unused, configuration): ResultError[] {
feature.children?.forEach(child => {
if (child.rule) {
test(child.rule.location, "Rule");
child.rule.children.forEach(child => testScenario(child.scenario));
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);
Expand Down

0 comments on commit 761b729

Please sign in to comment.