-
Notifications
You must be signed in to change notification settings - Fork 2
/
AssertionFormField.tsx
82 lines (69 loc) · 3.04 KB
/
AssertionFormField.tsx
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { ClassUnion, Mixin } from "typescript-mixin-class/index.js"
import { TextJSX } from "../../../jsx/TextJSX.js"
import { ExtComponent, TestSenchaPre } from "../TestSenchaPre.js"
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
export class AssertionFormField extends Mixin(
[ TestSenchaPre ],
(base : ClassUnion<typeof TestSenchaPre>) =>
class AssertionFormField extends base {
/**
* Passes if the passed Ext form field has the expected value.
*
* @param target A form field or a component query selector
* @param value A value to compare to.
* @param description The description of the assertion
*
* @category Sencha: Form field
*/
fieldHasValue (target : string | ExtComponent, value : unknown, description? : string) {
const field = this.resolveExtComponent(target)
this.assertEqualityInternal(
'fieldHasValue',
field.getValue() === value,
this.isAssertionNegated,
field.getValue(),
value,
description
)
}
/**
* Passes if the passed Ext form field has no value ("" or `null`).
*
* @param target A form field or a component query selector
* @param description The description of the assertion
*
* @category Sencha: Form field
*/
isFieldEmpty (target : string | ExtComponent, description? : string) {
const field = this.resolveExtComponent(target)
const value = field.getValue()
this.assertEqualityInternal(
'isFieldEmpty',
value == null || value === '',
this.isAssertionNegated,
value,
"",
description
)
}
/**
* Sets a value to an Ext Component. A faster way to set a value than manually calling "type" into
* a text field for example. A value is set by calling either the `setChecked` or `setRawValue` or
* `setValue` method of the component.
*
* @param component A component instance or a component query to resolve
* @param value
*
* @category Sencha: Form field
*/
setFieldValue (component : ExtComponent | string, value : unknown) {
component = this.resolveExtComponent(component);
// semi-colon needed
(component.setChecked || component.setRawValue || component.setValue).call(component, value)
}
// deprecated
setValue (component : ExtComponent | string, value : unknown) {
this.setFieldValue(component, value)
}
}
) {}