@@ -24,17 +24,7 @@ export interface HarnessLoader {
24
24
* @return A `HarnessLoader` rooted at the element matching the given selector.
25
25
* @throws If a matching element can't be found.
26
26
*/
27
- findRequired ( selector : string ) : Promise < HarnessLoader > ;
28
-
29
- /**
30
- * Searches for an element with the given selector under the current instances's root element,
31
- * and returns a `HarnessLoader` rooted at the matching element. If multiple elements match the
32
- * selector, the first is used. If no elements match, null is returned.
33
- * @param selector The selector for the root element of the new `HarnessLoader`
34
- * @return A `HarnessLoader` rooted at the element matching the given selector, or null if no
35
- * matching element was found.
36
- */
37
- findOptional ( selector : string ) : Promise < HarnessLoader | null > ;
27
+ getChildLoader ( selector : string ) : Promise < HarnessLoader > ;
38
28
39
29
/**
40
30
* Searches for all elements with the given selector under the current instances's root element,
@@ -43,7 +33,7 @@ export interface HarnessLoader {
43
33
* @param selector The selector for the root element of the new `HarnessLoader`
44
34
* @return A list of `HarnessLoader`s, one for each matching element, rooted at that element.
45
35
*/
46
- findAll ( selector : string ) : Promise < HarnessLoader [ ] > ;
36
+ getAllChildLoaders ( selector : string ) : Promise < HarnessLoader [ ] > ;
47
37
48
38
/**
49
39
* Searches for an instance of the component corresponding to the given harness type under the
@@ -54,27 +44,16 @@ export interface HarnessLoader {
54
44
* @return An instance of the given harness type
55
45
* @throws If a matching component instance can't be found.
56
46
*/
57
- requiredHarness < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
47
+ getHarness < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
58
48
Promise < T > ;
59
49
60
- /**
61
- * Searches for an instance of the component corresponding to the given harness type under the
62
- * `HarnessLoader`'s root element, and returns a `ComponentHarness` for that instance. If multiple
63
- * matching components are found, a harness for the first one is returned. If no matching
64
- * component is found, null is returned.
65
- * @param harnessType The type of harness to create
66
- * @return An instance of the given harness type, or null if none is found.
67
- */
68
- optionalHarness < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
69
- Promise < T | null > ;
70
-
71
50
/**
72
51
* Searches for all instances of the component corresponding to the given harness type under the
73
52
* `HarnessLoader`'s root element, and returns a list `ComponentHarness` for each instance.
74
53
* @param harnessType The type of harness to create
75
54
* @return A list instances of the given harness type.
76
55
*/
77
- allHarnesses < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
56
+ getAllHarnesses < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
78
57
Promise < T [ ] > ;
79
58
}
80
59
@@ -87,8 +66,8 @@ export interface LocatorFactory {
87
66
/** Gets a locator factory rooted at the document root. */
88
67
documentRootLocatorFactory ( ) : LocatorFactory ;
89
68
90
- /** Gets the root element of this `LocatorFactory` as a `TestElement`. */
91
- rootElement ( ) : TestElement ;
69
+ /** The root element of this `LocatorFactory` as a `TestElement`. */
70
+ rootElement : TestElement ;
92
71
93
72
/**
94
73
* Creates an asynchronous locator function that can be used to search for elements with the given
@@ -99,7 +78,7 @@ export interface LocatorFactory {
99
78
* @return An asynchronous locator function that searches for elements with the given selector,
100
79
* and either finds one or throws an error
101
80
*/
102
- locatorForRequired ( selector : string ) : AsyncFn < TestElement > ;
81
+ locatorFor ( selector : string ) : AsyncFn < TestElement > ;
103
82
104
83
/**
105
84
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` for a
@@ -110,7 +89,7 @@ export interface LocatorFactory {
110
89
* @return An asynchronous locator function that searches components matching the given harness
111
90
* type, and either returns a `ComponentHarness` for the component, or throws an error.
112
91
*/
113
- locatorForRequired < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
92
+ locatorFor < T extends ComponentHarness > ( harnessType : ComponentHarnessConstructor < T > ) :
114
93
AsyncFn < T > ;
115
94
116
95
/**
@@ -165,11 +144,11 @@ export interface LocatorFactory {
165
144
* should be inherited when defining user's own harness.
166
145
*/
167
146
export abstract class ComponentHarness {
168
- constructor ( private readonly locatorFacotry : LocatorFactory ) { }
147
+ constructor ( private readonly locatorFactory : LocatorFactory ) { }
169
148
170
149
/** Gets a `Promise` for the `TestElement` representing the host element of the component. */
171
150
async host ( ) : Promise < TestElement > {
172
- return this . locatorFacotry . rootElement ( ) ;
151
+ return this . locatorFactory . rootElement ;
173
152
}
174
153
175
154
/**
@@ -178,7 +157,7 @@ export abstract class ComponentHarness {
178
157
* appending to document.body).
179
158
*/
180
159
protected documentRootLocatorFactory ( ) : LocatorFactory {
181
- return this . locatorFacotry . documentRootLocatorFactory ( ) ;
160
+ return this . locatorFactory . documentRootLocatorFactory ( ) ;
182
161
}
183
162
184
163
/**
@@ -190,7 +169,7 @@ export abstract class ComponentHarness {
190
169
* @return An asynchronous locator function that searches for elements with the given selector,
191
170
* and either finds one or throws an error
192
171
*/
193
- protected locatorForRequired ( selector : string ) : AsyncFn < TestElement > ;
172
+ protected locatorFor ( selector : string ) : AsyncFn < TestElement > ;
194
173
195
174
/**
196
175
* Creates an asynchronous locator function that can be used to find a `ComponentHarness` for a
@@ -201,11 +180,11 @@ export abstract class ComponentHarness {
201
180
* @return An asynchronous locator function that searches components matching the given harness
202
181
* type, and either returns a `ComponentHarness` for the component, or throws an error.
203
182
*/
204
- protected locatorForRequired < T extends ComponentHarness > (
183
+ protected locatorFor < T extends ComponentHarness > (
205
184
harnessType : ComponentHarnessConstructor < T > ) : AsyncFn < T > ;
206
185
207
- protected locatorForRequired ( arg : any ) : any {
208
- return this . locatorFacotry . locatorForRequired ( arg ) ;
186
+ protected locatorFor ( arg : any ) : any {
187
+ return this . locatorFactory . locatorFor ( arg ) ;
209
188
}
210
189
211
190
/**
@@ -232,7 +211,7 @@ export abstract class ComponentHarness {
232
211
harnessType : ComponentHarnessConstructor < T > ) : AsyncFn < T | null > ;
233
212
234
213
protected locatorForOptional ( arg : any ) : any {
235
- return this . locatorFacotry . locatorForOptional ( arg ) ;
214
+ return this . locatorFactory . locatorForOptional ( arg ) ;
236
215
}
237
216
238
217
/**
@@ -258,7 +237,7 @@ export abstract class ComponentHarness {
258
237
AsyncFn < T [ ] > ;
259
238
260
239
protected locatorForAll ( arg : any ) : any {
261
- return this . locatorFacotry . locatorForAll ( arg ) ;
240
+ return this . locatorFactory . locatorForAll ( arg ) ;
262
241
}
263
242
}
264
243
0 commit comments