Skip to content

Commit

Permalink
Bugfix: incorrect table formatting when the first cell is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Mickael Burguet committed Feb 9, 2017
1 parent 2a8f9df commit 4f4dda4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ssense/cucumber-testrail-sync",
"version": "3.0.1",
"version": "3.0.2",
"description": "Synchronize test cases from TestRail & pushes Cucumber results",
"bin": {
"cucumber-testrail-sync": "./dist/bin/sync-test-cases.js",
Expand Down
7 changes: 6 additions & 1 deletion src/GherkinFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ export class GherkinFormatter {
arr.splice.apply(arr, (<any[]> [ tableStart, len ]).concat(
arr.filter((value: string, index: Number): boolean => {
return index >= tableStart && index < tableEnd;
}).map((line: string) => line.replace(/^(\|{2,})(.*)$/, '|$2|'))
}).map((line: string, index: number) => {
if (index === 0) {
return line.replace(/^(\|{2,})(.*)$/, '|$2|');
}
return line.replace(/^(\|{2})(.*)$/, '|$2|');
})
));
}

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/syncScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ describe('GherkinFormatter', () => {
expect(formatter.formatLinesFromTestrail({ custom_gherkin: gherkin })).to.deep.equal(expected);
});

it('formatLinesFromTestrail succeed when called with valid gherkin with tables #3', () => {
const gherkin = '|||:Header 1|:Header 2\n|| Line 1.1 | Line 1.2\n||| Line 2.2';
const expected = [ '|Header 1|Header 2|', '| Line 1.1 | Line 1.2|', '|| Line 2.2|'];

expect(formatter.formatLinesFromTestrail({ custom_gherkin: gherkin })).to.deep.equal(expected);
});

// In case of a hardcoded table, rows should end by a |
// | header1 | header2 |
// || value |
Expand Down

0 comments on commit 4f4dda4

Please sign in to comment.