/
types.ts
51 lines (45 loc) · 1.68 KB
/
types.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
41
42
43
44
45
46
47
48
49
50
51
export interface ToHaveOptions extends TextCompareOptions, ElementSelectorOptions, AttributeOptions, TreeOptions {
/** call `page.waitFor` before selecting. if a string that selector will be used on the call, and "selector" otherwise. If isNot then we wait for the elements matching selector to be hidden. */
waitForSelector?: boolean | string
}
type TextCompareMode = 'toContain' | 'toBeContainedBy' | 'equals' | 'startsWith' | 'endsWith'
export type ExtractAs = 'innerHTML' | 'outerHTML' | 'textContent' | 'innerText'
/** this apply not only to Text content but also to attribute values and any textual value */
export interface TextCompareOptions {
text?: string
caseInsensitive?: boolean
textCompareMode?: TextCompareMode // WIP
matchPattern?: RegExp //TODO
asCode?: boolean
extractAs?: ExtractAs
}
type Multiplicity = 'anyOf' | 'allOf'
interface ElementSelectorOptions {
/** parent.querySelectorAll() or use document if not given */
parent?: string
selector: string
matchElementCount?(n: number): boolean
matchElementCountDescription?: string
/** default is anyOf. Note that you can resolve "noneOf" using not() */
selectorMultiplicity?: Multiplicity // TODO
}
/**@internal */
export interface ToHaveAttribute {
name: string
value: string
}
interface AttributeOptions {
attributesNamed?: string[][] //TODO
attributes?: ToHaveAttribute[][] //TODO
attributesValued?: string[] //TODO
/** default is anyOf */
attributesMultiplicity?: Multiplicity //TODO
}
/** TODO: */
interface TreeOptions {
// parent?: ToHaveOptions // TODO
children?: ToHaveOptions // TODO
sibling?: ToHaveOptions // TODO
descendant?: ToHaveOptions // TODO
ancestor?: ToHaveOptions // TODO
}