forked from cucumber/cucumber-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenario.js
45 lines (41 loc) · 1.14 KB
/
scenario.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import _ from 'lodash'
import Gherkin from 'gherkin'
import Step from './step'
import Tag from './tag'
export default class Scenario {
constructor(options) {
const {
backgroundStepLines,
feature,
gherkinData,
language,
lineToDescriptionMapping,
stepLineToKeywordMapping
} = options
this.feature = feature
this.keyword = _.first(Gherkin.DIALECTS[language].scenario)
this.lines = _.map(gherkinData.locations, 'line')
this.name = gherkinData.name
this.tags = _.map(gherkinData.tags, Tag.build)
this.uri = gherkinData.locations[0].path
this.line = _.first(this.lines)
this.description = _.chain(this.lines)
.map((line) => lineToDescriptionMapping[line])
.compact()
.first()
.value()
let previousStep
this.steps = _.map(gherkinData.steps, (gherkinStepData) => {
const step = new Step({
backgroundLines: backgroundStepLines,
gherkinData: gherkinStepData,
language,
lineToKeywordMapping: stepLineToKeywordMapping,
previousStep,
scenario: this
})
previousStep = step
return step
})
}
}