gherkin-lint-ts
Version:
Gherkin features linter written in Typescript
46 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLanguageInsensitiveKeyword = exports.getNodeType = void 0;
const _ = require("lodash");
const Gherkin = require("gherkin").default;
// We use the node's keyword to determine the node's type
// because it's the only way to distinguish a scenario with a scenario outline
function getNodeType(node, language) {
const key = getLanguageInsensitiveKeyword(node, language).toLowerCase();
const stepKeys = [
"given",
"when",
"then",
"and",
"but",
];
if (key === "feature") {
return "Feature";
}
else if (key === "rule") {
return "Rule";
}
else if (key === "background") {
return "Background";
}
else if (key === "scenario") {
return "Scenario";
}
else if (key === "scenariooutline") {
return "Scenario Outline";
}
else if (key === "examples") {
return "Examples";
}
else if (stepKeys.includes(key)) {
return "Step";
}
return "";
}
exports.getNodeType = getNodeType;
function getLanguageInsensitiveKeyword(node, language) {
const languageMapping = Gherkin.dialects()[language || "en"];
return _.findKey(languageMapping, values => values instanceof Array && values.includes(node.keyword));
}
exports.getLanguageInsensitiveKeyword = getLanguageInsensitiveKeyword;
//# sourceMappingURL=gherkin.js.map