1
1
// @flow
2
2
3
3
import { throwError } from 'shared/util'
4
+ import { REF_SELECTOR } from 'shared/consts'
5
+ import { getSelectorType } from './get-selector'
6
+
7
+ const buildSelectorString = ( selector : Selector ) => {
8
+ if ( getSelectorType ( selector ) === REF_SELECTOR ) {
9
+ return `ref="${ selector . value . ref } "`
10
+ }
11
+
12
+ if ( typeof selector === 'string' ) {
13
+ return selector
14
+ }
15
+
16
+ return 'Component'
17
+ }
4
18
5
19
export default class ErrorWrapper implements BaseWrapper {
6
- selector : string
20
+ selector : Selector
7
21
8
- constructor ( selector : string ) {
22
+ constructor ( selector : Selector ) {
9
23
this . selector = selector
10
24
}
11
25
12
26
at ( ) : void {
13
27
throwError (
14
- `find did not return ${ this . selector } , cannot call at() on empty Wrapper`
28
+ `find did not return ${ buildSelectorString (
29
+ this . selector
30
+ ) } , cannot call at() on empty Wrapper`
15
31
)
16
32
}
17
33
18
34
attributes ( ) : void {
19
35
throwError (
20
- `find did not return ${ this . selector } , cannot call attributes() on empty Wrapper`
36
+ `find did not return ${ buildSelectorString (
37
+ this . selector
38
+ ) } , cannot call attributes() on empty Wrapper`
21
39
)
22
40
}
23
41
24
42
classes ( ) : void {
25
43
throwError (
26
- `find did not return ${ this . selector } , cannot call classes() on empty Wrapper`
44
+ `find did not return ${ buildSelectorString (
45
+ this . selector
46
+ ) } , cannot call classes() on empty Wrapper`
27
47
)
28
48
}
29
49
30
50
contains ( ) : void {
31
51
throwError (
32
- `find did not return ${ this . selector } , cannot call contains() on empty Wrapper`
52
+ `find did not return ${ buildSelectorString (
53
+ this . selector
54
+ ) } , cannot call contains() on empty Wrapper`
33
55
)
34
56
}
35
57
36
58
emitted ( ) : void {
37
59
throwError (
38
- `find did not return ${ this . selector } , cannot call emitted() on empty Wrapper`
60
+ `find did not return ${ buildSelectorString (
61
+ this . selector
62
+ ) } , cannot call emitted() on empty Wrapper`
39
63
)
40
64
}
41
65
42
66
emittedByOrder ( ) : void {
43
67
throwError (
44
- `find did not return ${ this . selector } , cannot call emittedByOrder() on empty Wrapper`
68
+ `find did not return ${ buildSelectorString (
69
+ this . selector
70
+ ) } , cannot call emittedByOrder() on empty Wrapper`
45
71
)
46
72
}
47
73
@@ -51,151 +77,201 @@ export default class ErrorWrapper implements BaseWrapper {
51
77
52
78
filter ( ) : void {
53
79
throwError (
54
- `find did not return ${ this . selector } , cannot call filter() on empty Wrapper`
80
+ `find did not return ${ buildSelectorString (
81
+ this . selector
82
+ ) } , cannot call filter() on empty Wrapper`
55
83
)
56
84
}
57
85
58
86
visible ( ) : void {
59
87
throwError (
60
- `find did not return ${ this . selector } , cannot call visible() on empty Wrapper`
88
+ `find did not return ${ buildSelectorString (
89
+ this . selector
90
+ ) } , cannot call visible() on empty Wrapper`
61
91
)
62
92
}
63
93
64
94
hasAttribute ( ) : void {
65
95
throwError (
66
- `find did not return ${ this . selector } , cannot call hasAttribute() on empty Wrapper`
96
+ `find did not return ${ buildSelectorString (
97
+ this . selector
98
+ ) } , cannot call hasAttribute() on empty Wrapper`
67
99
)
68
100
}
69
101
70
102
hasClass ( ) : void {
71
103
throwError (
72
- `find did not return ${ this . selector } , cannot call hasClass() on empty Wrapper`
104
+ `find did not return ${ buildSelectorString (
105
+ this . selector
106
+ ) } , cannot call hasClass() on empty Wrapper`
73
107
)
74
108
}
75
109
76
110
hasProp ( ) : void {
77
111
throwError (
78
- `find did not return ${ this . selector } , cannot call hasProp() on empty Wrapper`
112
+ `find did not return ${ buildSelectorString (
113
+ this . selector
114
+ ) } , cannot call hasProp() on empty Wrapper`
79
115
)
80
116
}
81
117
82
118
hasStyle ( ) : void {
83
119
throwError (
84
- `find did not return ${ this . selector } , cannot call hasStyle() on empty Wrapper`
120
+ `find did not return ${ buildSelectorString (
121
+ this . selector
122
+ ) } , cannot call hasStyle() on empty Wrapper`
85
123
)
86
124
}
87
125
88
126
findAll ( ) : void {
89
127
throwError (
90
- `find did not return ${ this . selector } , cannot call findAll() on empty Wrapper`
128
+ `find did not return ${ buildSelectorString (
129
+ this . selector
130
+ ) } , cannot call findAll() on empty Wrapper`
91
131
)
92
132
}
93
133
94
134
find ( ) : void {
95
135
throwError (
96
- `find did not return ${ this . selector } , cannot call find() on empty Wrapper`
136
+ `find did not return ${ buildSelectorString (
137
+ this . selector
138
+ ) } , cannot call find() on empty Wrapper`
97
139
)
98
140
}
99
141
100
142
html ( ) : void {
101
143
throwError (
102
- `find did not return ${ this . selector } , cannot call html() on empty Wrapper`
144
+ `find did not return ${ buildSelectorString (
145
+ this . selector
146
+ ) } , cannot call html() on empty Wrapper`
103
147
)
104
148
}
105
149
106
150
is ( ) : void {
107
151
throwError (
108
- `find did not return ${ this . selector } , cannot call is() on empty Wrapper`
152
+ `find did not return ${ buildSelectorString (
153
+ this . selector
154
+ ) } , cannot call is() on empty Wrapper`
109
155
)
110
156
}
111
157
112
158
isEmpty ( ) : void {
113
159
throwError (
114
- `find did not return ${ this . selector } , cannot call isEmpty() on empty Wrapper`
160
+ `find did not return ${ buildSelectorString (
161
+ this . selector
162
+ ) } , cannot call isEmpty() on empty Wrapper`
115
163
)
116
164
}
117
165
118
166
isVisible ( ) : void {
119
167
throwError (
120
- `find did not return ${ this . selector } , cannot call isVisible() on empty Wrapper`
168
+ `find did not return ${ buildSelectorString (
169
+ this . selector
170
+ ) } , cannot call isVisible() on empty Wrapper`
121
171
)
122
172
}
123
173
124
174
isVueInstance ( ) : void {
125
175
throwError (
126
- `find did not return ${ this . selector } , cannot call isVueInstance() on empty Wrapper`
176
+ `find did not return ${ buildSelectorString (
177
+ this . selector
178
+ ) } , cannot call isVueInstance() on empty Wrapper`
127
179
)
128
180
}
129
181
130
182
name ( ) : void {
131
183
throwError (
132
- `find did not return ${ this . selector } , cannot call name() on empty Wrapper`
184
+ `find did not return ${ buildSelectorString (
185
+ this . selector
186
+ ) } , cannot call name() on empty Wrapper`
133
187
)
134
188
}
135
189
136
190
props ( ) : void {
137
191
throwError (
138
- `find did not return ${ this . selector } , cannot call props() on empty Wrapper`
192
+ `find did not return ${ buildSelectorString (
193
+ this . selector
194
+ ) } , cannot call props() on empty Wrapper`
139
195
)
140
196
}
141
197
142
198
text ( ) : void {
143
199
throwError (
144
- `find did not return ${ this . selector } , cannot call text() on empty Wrapper`
200
+ `find did not return ${ buildSelectorString (
201
+ this . selector
202
+ ) } , cannot call text() on empty Wrapper`
145
203
)
146
204
}
147
205
148
206
setComputed ( ) : void {
149
207
throwError (
150
- `find did not return ${ this . selector } , cannot call setComputed() on empty Wrapper`
208
+ `find did not return ${ buildSelectorString (
209
+ this . selector
210
+ ) } , cannot call setComputed() on empty Wrapper`
151
211
)
152
212
}
153
213
154
214
setData ( ) : void {
155
215
throwError (
156
- `find did not return ${ this . selector } , cannot call setData() on empty Wrapper`
216
+ `find did not return ${ buildSelectorString (
217
+ this . selector
218
+ ) } , cannot call setData() on empty Wrapper`
157
219
)
158
220
}
159
221
160
222
setMethods ( ) : void {
161
223
throwError (
162
- `find did not return ${ this . selector } , cannot call setMethods() on empty Wrapper`
224
+ `find did not return ${ buildSelectorString (
225
+ this . selector
226
+ ) } , cannot call setMethods() on empty Wrapper`
163
227
)
164
228
}
165
229
166
230
setProps ( ) : void {
167
231
throwError (
168
- `find did not return ${ this . selector } , cannot call setProps() on empty Wrapper`
232
+ `find did not return ${ buildSelectorString (
233
+ this . selector
234
+ ) } , cannot call setProps() on empty Wrapper`
169
235
)
170
236
}
171
237
172
238
setValue ( ) : void {
173
239
throwError (
174
- `find did not return ${ this . selector } , cannot call setValue() on empty Wrapper`
240
+ `find did not return ${ buildSelectorString (
241
+ this . selector
242
+ ) } , cannot call setValue() on empty Wrapper`
175
243
)
176
244
}
177
245
178
246
setChecked ( ) : void {
179
247
throwError (
180
- `find did not return ${ this . selector } , cannot call setChecked() on empty Wrapper`
248
+ `find did not return ${ buildSelectorString (
249
+ this . selector
250
+ ) } , cannot call setChecked() on empty Wrapper`
181
251
)
182
252
}
183
253
184
254
setSelected ( ) : void {
185
255
throwError (
186
- `find did not return ${ this . selector } , cannot call setSelected() on empty Wrapper`
256
+ `find did not return ${ buildSelectorString (
257
+ this . selector
258
+ ) } , cannot call setSelected() on empty Wrapper`
187
259
)
188
260
}
189
261
190
262
trigger ( ) : void {
191
263
throwError (
192
- `find did not return ${ this . selector } , cannot call trigger() on empty Wrapper`
264
+ `find did not return ${ buildSelectorString (
265
+ this . selector
266
+ ) } , cannot call trigger() on empty Wrapper`
193
267
)
194
268
}
195
269
196
270
destroy ( ) : void {
197
271
throwError (
198
- `find did not return ${ this . selector } , cannot call destroy() on empty Wrapper`
272
+ `find did not return ${ buildSelectorString (
273
+ this . selector
274
+ ) } , cannot call destroy() on empty Wrapper`
199
275
)
200
276
}
201
277
}
0 commit comments