@@ -45,14 +45,20 @@ const defaultOptions: Required<UserEventSetupOptions> = {
45
45
* Creates a new instance of user event instance with the given options.
46
46
*
47
47
* @param options
48
- * @returns
48
+ * @returns UserEvent instance
49
49
*/
50
50
export function setup ( options ?: UserEventSetupOptions ) {
51
51
const config = createConfig ( options ) ;
52
52
const instance = createInstance ( config ) ;
53
53
return instance ;
54
54
}
55
55
56
+ /**
57
+ * Options affecting all user event interactions.
58
+ *
59
+ * @param delay between some subsequent inputs like typing a series of characters
60
+ * @param advanceTimers function to be called to advance fake timers
61
+ */
56
62
export interface UserEventConfig {
57
63
delay : number ;
58
64
advanceTimers : ( delay : number ) => Promise < void > | void ;
@@ -65,9 +71,34 @@ function createConfig(options?: UserEventSetupOptions): UserEventConfig {
65
71
} ;
66
72
}
67
73
74
+ /**
75
+ * UserEvent instance used to invoke user interaction functions.
76
+ */
68
77
export interface UserEventInstance {
69
78
config : UserEventConfig ;
79
+
70
80
press : ( element : ReactTestInstance ) => Promise < void > ;
81
+
82
+ /**
83
+ * Simulate user pressing on given `TextInput` element and typing given text.
84
+ *
85
+ * This method will trigger the events for each character of the text:
86
+ * `keyPress`, `change`, `changeText`, `endEditing`, etc.
87
+ *
88
+ * It will also trigger events connected with entering and leaving the text
89
+ * input.
90
+ *
91
+ * The exact events sent depend on the props of TextInput (`editable`,
92
+ * `multiline`, value, defaultValue, etc) and passed options.
93
+ *
94
+ * @param element TextInput element to type on
95
+ * @param text Text to type
96
+ * @param options Options affecting typing behavior:
97
+ * - `skipPress` - if true, `pressIn` and `pressOut` events will not be
98
+ * triggered.
99
+ * - `submitEditing` - if true, `submitEditing` event will be triggered after
100
+ * typing the text.
101
+ */
71
102
type : (
72
103
element : ReactTestInstance ,
73
104
text : string ,
0 commit comments