-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground-setup-only.ts
35 lines (29 loc) · 1001 Bytes
/
background-setup-only.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
35
import { switchOrSeveritySchema } from '../schemas'
import Schema from '../schema'
import Rule from '../rule'
import { RawSchema, AcceptedSchema } from '../types'
import Document from '../document'
export default class BackgroundSetupOnly implements Rule {
public readonly name: string = 'background-setup-only'
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.background) {
return
}
child.background.steps.forEach((step): void => {
if (!['Given', '*'].includes(step.keyword.trim())) {
document.addError(
this,
`Background should only be used for set up. Found "${step.keyword.trim()}".`,
step.location,
)
}
})
})
}
}