Skip to content

Add a 'reindent' test helper #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
"mustache": "4.2.0",
"nyc": "15.1.0",
"prettier": "2.3.2",
"reindent-template-literals": "^1.0.0",
"semver": "7.3.5",
"sinon": "11.1.1",
"sinon-chai": "3.7.0",
Expand Down
111 changes: 60 additions & 51 deletions src/formatter/helpers/gherkin_document_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../../test/gherkin_helpers'
import * as messages from '@cucumber/messages'
import IGherkinDocument = messages.GherkinDocument
import { reindent } from 'reindent-template-literals'

describe('GherkinDocumentParser', () => {
describe('getGherkinStepMap', () => {
Expand Down Expand Up @@ -315,64 +316,72 @@ async function parseGherkinDocument(data: string): Promise<IGherkinDocument> {
}

async function withBackgroundAndScenario(): Promise<IGherkinDocument> {
return await parseGherkinDocument(`\
Feature: a feature
Background:
Given a setup step

Scenario:
When a regular step
`)
return await parseGherkinDocument(
reindent(`
Feature: a feature
Background:
Given a setup step

Scenario:
When a regular step
`)
)
}

async function withBackgroundAndScenarioOutline(): Promise<IGherkinDocument> {
return await parseGherkinDocument(`\
Feature: a feature
Background:
Given a setup step

Scenario Outline:
When a templated step with <word>
Examples:
| word |
| foo |
| bar |
`)
return await parseGherkinDocument(
reindent(`
Feature: a feature
Background:
Given a setup step

Scenario Outline:
When a templated step with <word>
Examples:
| word |
| foo |
| bar |
`)
)
}

async function withBackgroundAndRuleWithExamples(): Promise<IGherkinDocument> {
return await parseGherkinDocument(`\
Feature: a feature
Background:
Given a setup step

Rule: a rule
Example: an example
When a regular step
Then an assertion

Example: another example
When a regular step
Then an assertion
`)
return await parseGherkinDocument(
reindent(`
Feature: a feature
Background:
Given a setup step

Rule: a rule
Example: an example
When a regular step
Then an assertion

Example: another example
When a regular step
Then an assertion
`)
)
}

async function withBackgroundAndRuleWithBackgroundAndExamples(): Promise<IGherkinDocument> {
return await parseGherkinDocument(`\
Feature: a feature
Background:
Given a feature-level setup step

Rule: a rule
Background:
Given a rule-level setup step

Example: an example
When a regular step
Then an assertion

Example: another example
When a regular step
Then an assertion
`)
return await parseGherkinDocument(
reindent(`
Feature: a feature
Background:
Given a feature-level setup step

Rule: a rule
Background:
Given a rule-level setup step

Example: an example
When a regular step
Then an assertion

Example: another example
When a regular step
Then an assertion
`)
)
}
Loading