forked from cucumber/cucumber-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_step_hook_definition.ts
34 lines (30 loc) · 1 KB
/
test_step_hook_definition.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 { PickleTagFilter } from '../pickle_filter'
import Definition, {
IDefinition,
IGetInvocationDataResponse,
IGetInvocationDataRequest,
IDefinitionParameters,
IHookDefinitionOptions,
} from './definition'
import { messages } from 'cucumber-messages'
export default class TestStepHookDefinition extends Definition
implements IDefinition {
private readonly pickleTagFilter: PickleTagFilter
constructor(data: IDefinitionParameters<IHookDefinitionOptions>) {
super(data)
this.pickleTagFilter = new PickleTagFilter(data.options.tags)
}
appliesToTestCase(pickle: messages.IPickle): boolean {
return this.pickleTagFilter.matchesAllTagExpressions(pickle)
}
async getInvocationParameters({
hookParameter,
}: IGetInvocationDataRequest): Promise<IGetInvocationDataResponse> {
return Promise.resolve({
getInvalidCodeLengthMessage: () =>
this.buildInvalidCodeLengthMessage('0 or 1', '2'),
parameters: [hookParameter],
validCodeLengths: [0, 1, 2],
})
}
}