Skip to content

Commit

Permalink
Added more test cases and adjusted regex Feature: keyword as text
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarGi committed Jul 4, 2022
1 parent d10e18e commit 621c124
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion server/src/regex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
globalMatch: {
feature: /(?<!\S)Feature:/g,
feature: /(?<!\S)(?:^| )Feature:/gm,
beginningStep:
/(?<=(Background:|Scenario( (Outline|Template))?:|Example:)(.*)[\n\r](\s)*)(Given|When|Then|And|But)(?= )/g,
docString: /"""[\s\S]*?"""/g,
Expand Down
19 changes: 6 additions & 13 deletions server/tests/unit/rules/only_one_feature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ const testCases = [
['Feature: - Feature:', 'Feature: Feature name\nFeature:', [buildLintInfo(22, 30)]],
['Feature: - Feature Description', 'Feature: Feature name\n Feature Description', []],
['Feature: - feature: Description', 'Feature: Feature name\n feature: Description', []],
['Feature: - Feature: Description', 'Feature: Feature name\n Feature: Description', [buildLintInfo(26, 34)]],
['Feature: - Feature: Description', 'Feature: Feature name\n Feature: Description', [buildLintInfo(25, 34)]],
['Tag - Feature:', '@tag\nFeature: Feature name', []],
['MultipleTags - Feature:', '@tag1\n@tag2 @tag3 @tag4\nFeature: Feature name', []],
['Feature: - Background: - Feature:', 'Feature: Feature name\n Feature Description\n\n Background: Background name\n Given a step\n\nFeature:\n', [buildLintInfo(101, 109)]],
['Feature: - Scenario: - Feature:', 'Feature: Feature name\n Feature Description\n\n Scenario: Scenario name\n Given a step\n\nFeature:\n', [buildLintInfo(97, 105)]],
['Feature: - Scenario Outline: - Feature:', 'Feature: Feature name\n Feature Description\n\n Scenario Outline: Scenario Outline name\n\nFeature:\n', [buildLintInfo(96, 104)]],
['Feature: - Background: - Scenario: - Scenario Outline: - Feature:', 'Feature: Feature name\n Feature Description\n Background: Background name\n Scenario: Scenario name\n Scenario Outline: Scenario Outline name \nFeature:\n', [buildLintInfo(152, 160)]],

['Feature: - Feature: as text', 'Feature: Feature name\n This is Feature: description\n', []],
['Comment with Feature: - Feature:', '# comment Feature: section\nFeature: Feature name\n', []],
['Multiple Feature: - Feature: as text', 'Feature: Feature 1 Description\nFeature: Feature 2 Description\nFeature: Feature 3 Description\n This is a Feature: description\n', [buildLintInfo(31, 39),buildLintInfo(62, 70)]],
['Multiple Feature: - Multiple Feature: as text', '# There should be only one Feature: keyword \nFeature: Feature 1 Description\nFeature: Feature 2 Description\nFeature: Feature 3 Description\n This is a Feature: description1\n This is a Feature: description2\n', [buildLintInfo(76, 84),buildLintInfo(107, 115)]],
['Feature: - Whitespace Feature: - Feature: as text', 'Feature: Feature 1 Description\n Feature: Feature 2 Description\n This is a Feature: description\n', [buildLintInfo(34, 43)]],
];

describe('Rule: Feature file must have only one feature keyword ', function () {
Expand All @@ -25,17 +29,6 @@ describe('Rule: Feature file must have only one feature keyword ', function () {
});
});

// This test needs to be passed but is failing while linting
// This test case can be added to above testscases after the following issue has been solved
// https://github.com/gherlint/gherlint-vscode/issues/16
describe('Tests expected to pass but failing ', function () {
test.failing('Feature: as a text but not keyword', () => {
const problems = Rule.run('Feature: Feature name\n This Feature: is not a keyword');
const expected = []
assert.deepEqual(problems, expected);
});
});

function buildLintInfo(startIndex, endIndex) {
return {
startIndex,
Expand Down

0 comments on commit 621c124

Please sign in to comment.