-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
test_case_hook_definition.ts
40 lines (36 loc) · 1.16 KB
/
test_case_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
35
36
37
38
39
40
import { PickleTagFilter } from '../pickle_filter'
import Definition, {
IDefinition,
IDefinitionParameters,
IGetInvocationDataRequest,
IGetInvocationDataResponse,
IHookDefinitionOptions,
} from './definition'
import * as messages from '@cucumber/messages'
export default class TestCaseHookDefinition
extends Definition
implements IDefinition
{
public readonly name: string
public readonly tagExpression: string
private readonly pickleTagFilter: PickleTagFilter
constructor(data: IDefinitionParameters<IHookDefinitionOptions>) {
super(data)
this.name = data.options.name
this.tagExpression = data.options.tags
this.pickleTagFilter = new PickleTagFilter(data.options.tags)
}
appliesToTestCase(pickle: messages.Pickle): boolean {
return this.pickleTagFilter.matchesAllTagExpressions(pickle)
}
async getInvocationParameters({
hookParameter,
}: IGetInvocationDataRequest): Promise<IGetInvocationDataResponse> {
return await Promise.resolve({
getInvalidCodeLengthMessage: () =>
this.buildInvalidCodeLengthMessage('0 or 1', '2'),
parameters: [hookParameter],
validCodeLengths: [0, 1, 2],
})
}
}