Skip to content

Commit

Permalink
autofix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Jun 4, 2021
1 parent 676a7dc commit 65314df
Show file tree
Hide file tree
Showing 24 changed files with 91 additions and 124 deletions.
3 changes: 1 addition & 2 deletions features/fixtures/formatters/passed-rule.message.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module.exports = [
{
source: {
uri: 'features/a.feature',
data:
'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
data: 'Feature: a feature\n Rule: a rule\n Example: an example\n Given a step',
mediaType: 'text/x.cucumber.gherkin+plain',
},
},
Expand Down
49 changes: 14 additions & 35 deletions src/cli/configuration_builder_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -99,11 +96,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -124,11 +118,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -151,11 +142,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeFeaturePath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([featurePath])
Expand All @@ -175,11 +163,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand All @@ -199,11 +184,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand All @@ -223,11 +205,8 @@ describe('Configuration', () => {
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })
const { featurePaths, pickleFilterOptions, supportCodePaths } =
await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
Expand Down
4 changes: 3 additions & 1 deletion src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export default class Cli {
supportCodeLibrary,
}
if (doesNotHaveValue(formatOptions.colorsEnabled)) {
typeOptions.parsedArgvOptions.colorsEnabled = (stream as TtyWriteStream).isTTY
typeOptions.parsedArgvOptions.colorsEnabled = (
stream as TtyWriteStream
).isTTY
}
if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {
const outputToName = outputTo === '' ? 'stdout' : outputTo
Expand Down
10 changes: 4 additions & 6 deletions src/formatter/helpers/event_data_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ export default class EventDataCollector {
testStepId,
testStepResult,
}: messages.TestStepFinished): void {
this.testCaseAttemptDataMap[testCaseStartedId].stepResults[
testStepId
] = testStepResult
this.testCaseAttemptDataMap[testCaseStartedId].stepResults[testStepId] =
testStepResult
}

storeTestCaseResult({ testCaseStartedId }: messages.TestCaseFinished): void {
const stepResults = values(
this.testCaseAttemptDataMap[testCaseStartedId].stepResults
)
this.testCaseAttemptDataMap[
testCaseStartedId
].worstTestStepResult = messages.getWorstTestStepResult(stepResults)
this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult =
messages.getWorstTestStepResult(stepResults)
}
}
5 changes: 2 additions & 3 deletions src/formatter/helpers/gherkin_document_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ export function getGherkinScenarioLocationMap(
gherkinDocument: messages.GherkinDocument
): Record<string, messages.Location> {
const locationMap: Record<string, messages.Location> = {}
const scenarioMap: Record<string, messages.Scenario> = getGherkinScenarioMap(
gherkinDocument
)
const scenarioMap: Record<string, messages.Scenario> =
getGherkinScenarioMap(gherkinDocument)
_.entries<messages.Scenario>(scenarioMap).forEach(([id, scenario]) => {
locationMap[id] = scenario.location
if (doesHaveValue(scenario.examples)) {
Expand Down
12 changes: 8 additions & 4 deletions src/formatter/helpers/gherkin_document_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = getGherkinStepMap(gherkinDocument)
Expand Down Expand Up @@ -156,7 +157,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = getGherkinScenarioMap(gherkinDocument)
Expand Down Expand Up @@ -215,7 +217,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = await getGherkinExampleRuleMap(gherkinDocument)
Expand Down Expand Up @@ -284,7 +287,8 @@ describe('GherkinDocumentParser', () => {

it('works for a Background and Rule with its own Background and Examples', async () => {
// Arrange
const gherkinDocument = await withBackgroundAndRuleWithBackgroundAndExamples()
const gherkinDocument =
await withBackgroundAndRuleWithBackgroundAndExamples()

// Act
const output = await getGherkinScenarioLocationMap(gherkinDocument)
Expand Down
5 changes: 2 additions & 3 deletions src/formatter/helpers/pickle_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function getPickleLocation({
gherkinDocument,
pickle,
}: IGetPickleLocationRequest): messages.Location {
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
return gherkinScenarioLocationMap[_.last(pickle.astNodeIds)]
}
5 changes: 2 additions & 3 deletions src/formatter/helpers/test_case_attempt_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ export function parseTestCaseAttempt({
}: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt {
const { testCase, pickle, gherkinDocument } = testCaseAttempt
const gherkinStepMap = getGherkinStepMap(gherkinDocument)
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
const pickleStepMap = getPickleStepMap(pickle)
const relativePickleUri = pickle.uri
const parsedTestCase: IParsedTestCase = {
Expand Down
10 changes: 4 additions & 6 deletions src/formatter/helpers/usage_helpers/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ describe('Usage Helpers', () => {
const supportCodeLibrary = buildSupportCodeLibrary(({ Given }) => {
Given('a step', code)
})
const {
eventDataCollector,
} = await getEnvelopesAndEventDataCollector({ supportCodeLibrary })
const { eventDataCollector } =
await getEnvelopesAndEventDataCollector({ supportCodeLibrary })

// Act
const output = getUsage({
Expand Down Expand Up @@ -53,9 +52,8 @@ describe('Usage Helpers', () => {
)
}
)
const {
eventDataCollector,
} = await getEnvelopesAndEventDataCollector({ supportCodeLibrary })
const { eventDataCollector } =
await getEnvelopesAndEventDataCollector({ supportCodeLibrary })

// Act
const output = getUsage({
Expand Down
12 changes: 4 additions & 8 deletions src/formatter/json_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import { parseStepArgument } from '../step_arguments'

const { getGherkinStepMap, getGherkinScenarioMap } = GherkinDocumentParser

const {
getScenarioDescription,
getPickleStepMap,
getStepKeyword,
} = PickleParser
const { getScenarioDescription, getPickleStepMap, getStepKeyword } =
PickleParser

export interface IJsonFeature {
description: string
Expand Down Expand Up @@ -148,9 +145,8 @@ export default class JsonFormatter extends Formatter {
const gherkinStepMap = getGherkinStepMap(gherkinDocument)
const gherkinScenarioMap = getGherkinScenarioMap(gherkinDocument)
const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)
const gherkinScenarioLocationMap = getGherkinScenarioLocationMap(
gherkinDocument
)
const gherkinScenarioLocationMap =
getGherkinScenarioLocationMap(gherkinDocument)
const elements = group.map((testCaseAttempt: ITestCaseAttempt) => {
const { pickle } = testCaseAttempt
const pickleStepMap = getPickleStepMap(pickle)
Expand Down
8 changes: 4 additions & 4 deletions src/formatter/json_formatter_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ describe('JsonFormatter', () => {
})

// Assert
const stepArguments = JSON.parse(output)[0].elements[0].steps[0]
.arguments
const stepArguments =
JSON.parse(output)[0].elements[0].steps[0].arguments
expect(stepArguments).to.eql([
{
content: 'This is a DocString',
Expand Down Expand Up @@ -359,8 +359,8 @@ describe('JsonFormatter', () => {
})

// Assert
const stepArguments = JSON.parse(output)[0].elements[0].steps[0]
.arguments
const stepArguments =
JSON.parse(output)[0].elements[0].steps[0].arguments
expect(stepArguments).to.eql([
{
rows: [
Expand Down
5 changes: 2 additions & 3 deletions src/formatter/progress_bar_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export default class ProgressBarFormatter extends Formatter {
testStepId,
testCaseStartedId,
}: messages.TestStepFinished): void {
const { testCase } = this.eventDataCollector.getTestCaseAttempt(
testCaseStartedId
)
const { testCase } =
this.eventDataCollector.getTestCaseAttempt(testCaseStartedId)
const testStep = testCase.testSteps.find((s) => s.id === testStepId)
if (doesHaveValue(testStep.pickleStepId)) {
this.progressBar.tick()
Expand Down
15 changes: 6 additions & 9 deletions src/formatter/progress_bar_formatter_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand All @@ -125,8 +124,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nRule: b\nExample: c\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nRule: b\nExample: c\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand All @@ -149,8 +147,7 @@ describe('ProgressBarFormatter', () => {
uri: 'a.feature',
},
{
data:
'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
data: 'Feature: a\nScenario: b\nGiven a step\nWhen a step\nThen a step',
uri: 'b.feature',
},
]
Expand Down Expand Up @@ -370,8 +367,7 @@ describe('ProgressBarFormatter', () => {
// Arrange
const sources = [
{
data:
'Feature: a\nScenario: b\nGiven a passing step\n When a flaky step\nThen a passing step',
data: 'Feature: a\nScenario: b\nGiven a passing step\n When a flaky step\nThen a passing step',
uri: 'a.feature',
},
]
Expand All @@ -384,7 +380,8 @@ describe('ProgressBarFormatter', () => {
sources,
supportCodeLibrary,
})
const progressBar = progressBarFormatter.progressBar as sinon.SinonStubbedInstance<ProgressBar>
const progressBar =
progressBarFormatter.progressBar as sinon.SinonStubbedInstance<ProgressBar>

// Assert
expect(progressBar.interrupt).to.have.callCount(1)
Expand Down
20 changes: 9 additions & 11 deletions src/formatter/progress_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ import * as messages from '@cucumber/messages'
import IEnvelope = messages.Envelope
import ITestStepFinished = messages.TestStepFinished

const STATUS_CHARACTER_MAPPING: Map<
messages.TestStepResultStatus,
string
> = new Map([
[messages.TestStepResultStatus.AMBIGUOUS, 'A'],
[messages.TestStepResultStatus.FAILED, 'F'],
[messages.TestStepResultStatus.PASSED, '.'],
[messages.TestStepResultStatus.PENDING, 'P'],
[messages.TestStepResultStatus.SKIPPED, '-'],
[messages.TestStepResultStatus.UNDEFINED, 'U'],
])
const STATUS_CHARACTER_MAPPING: Map<messages.TestStepResultStatus, string> =
new Map([
[messages.TestStepResultStatus.AMBIGUOUS, 'A'],
[messages.TestStepResultStatus.FAILED, 'F'],
[messages.TestStepResultStatus.PASSED, '.'],
[messages.TestStepResultStatus.PENDING, 'P'],
[messages.TestStepResultStatus.SKIPPED, '-'],
[messages.TestStepResultStatus.UNDEFINED, 'U'],
])

export default class ProgressFormatter extends SummaryFormatter {
constructor(options: IFormatterOptions) {
Expand Down
7 changes: 4 additions & 3 deletions src/formatter/rerun_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ export default class RerunFormatter extends Formatter {
worstTestStepResult.status !== messages.TestStepResultStatus.PASSED
) {
const relativeUri = pickle.uri
const line = getGherkinScenarioLocationMap(gherkinDocument)[
_.last(pickle.astNodeIds)
].line
const line =
getGherkinScenarioLocationMap(gherkinDocument)[
_.last(pickle.astNodeIds)
].line
if (doesNotHaveValue(mapping[relativeUri])) {
mapping[relativeUri] = []
}
Expand Down
Loading

0 comments on commit 65314df

Please sign in to comment.