-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenario-verification.ts
34 lines (28 loc) · 984 Bytes
/
scenario-verification.ts
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
import { switchOrSeveritySchema } from '../schemas'
import Schema from '../schema'
import Rule from '../rule'
import { RawSchema, AcceptedSchema } from '../types'
import Document from '../document'
export default class ScenarioVerification implements Rule {
public readonly name: string = 'scenario-verification'
public readonly acceptedSchema: AcceptedSchema = switchOrSeveritySchema
public readonly schema: Schema
public constructor(rawSchema: RawSchema) {
this.schema = new Schema(rawSchema)
}
public async run(document: Document): Promise<void> {
document.feature.children.forEach((child) => {
if (!child.scenario) {
return
}
const whens = child.scenario.steps.filter((s) => s.keyword.trim() === 'Then')
if (whens.length === 0) {
document.addError(
this,
'Scenario should contain a "Then" to denote verification of an action.',
child.scenario.location,
)
}
})
}
}