Skip to content

Commit ff4e0fc

Browse files
committed
chore: Remove selectorString from ErrorWrapper
1 parent aab0bf5 commit ff4e0fc

File tree

2 files changed

+98
-101
lines changed

2 files changed

+98
-101
lines changed

Diff for: packages/test-utils/src/error-wrapper.js

+93-97
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,56 @@ const buildSelectorString = (selector: Selector) => {
1818

1919
export default class ErrorWrapper implements BaseWrapper {
2020
selector: Selector
21-
selectorString: string
2221

2322
constructor(selector: Selector) {
2423
this.selector = selector
25-
this.selectorString = buildSelectorString(selector)
2624
}
2725

2826
at(): void {
2927
throwError(
30-
`find did not return ${
31-
this.selectorString
32-
}, cannot call at() on empty Wrapper`
28+
`find did not return ${buildSelectorString(
29+
this.selector
30+
)}, cannot call at() on empty Wrapper`
3331
)
3432
}
3533

3634
attributes(): void {
3735
throwError(
38-
`find did not return ${
39-
this.selectorString
40-
}, cannot call attributes() on empty Wrapper`
41-
36+
`find did not return ${buildSelectorString(
37+
this.selector
38+
)}, cannot call attributes() on empty Wrapper`
4239
)
4340
}
4441

4542
classes(): void {
4643
throwError(
47-
`find did not return ${
48-
this.selectorString
49-
}, cannot call classes() on empty Wrapper`
50-
44+
`find did not return ${buildSelectorString(
45+
this.selector
46+
)}, cannot call classes() on empty Wrapper`
5147
)
5248
}
5349

5450
contains(): void {
5551
throwError(
56-
`find did not return ${
57-
this.selectorString
58-
}, cannot call contains() on empty Wrapper`
52+
`find did not return ${buildSelectorString(
53+
this.selector
54+
)}, cannot call contains() on empty Wrapper`
5955
)
6056
}
6157

6258
emitted(): void {
6359
throwError(
64-
`find did not return ${
65-
this.selectorString
66-
}, cannot call emitted() on empty Wrapper`
60+
`find did not return ${buildSelectorString(
61+
this.selector
62+
)}, cannot call emitted() on empty Wrapper`
6763
)
6864
}
6965

7066
emittedByOrder(): void {
7167
throwError(
72-
`find did not return ${
73-
this.selectorString
74-
}, cannot call emittedByOrder() on empty Wrapper`
68+
`find did not return ${buildSelectorString(
69+
this.selector
70+
)}, cannot call emittedByOrder() on empty Wrapper`
7571
)
7672
}
7773

@@ -81,201 +77,201 @@ export default class ErrorWrapper implements BaseWrapper {
8177

8278
filter(): void {
8379
throwError(
84-
`find did not return ${
85-
this.selectorString
86-
}, cannot call filter() on empty Wrapper`
80+
`find did not return ${buildSelectorString(
81+
this.selector
82+
)}, cannot call filter() on empty Wrapper`
8783
)
8884
}
8985

9086
visible(): void {
9187
throwError(
92-
`find did not return ${
93-
this.selectorString
94-
}, cannot call visible() on empty Wrapper`
88+
`find did not return ${buildSelectorString(
89+
this.selector
90+
)}, cannot call visible() on empty Wrapper`
9591
)
9692
}
9793

9894
hasAttribute(): void {
9995
throwError(
100-
`find did not return ${
101-
this.selectorString
102-
}, cannot call hasAttribute() on empty Wrapper`
96+
`find did not return ${buildSelectorString(
97+
this.selector
98+
)}, cannot call hasAttribute() on empty Wrapper`
10399
)
104100
}
105101

106102
hasClass(): void {
107103
throwError(
108-
`find did not return ${
109-
this.selectorString
110-
}, cannot call hasClass() on empty Wrapper`
104+
`find did not return ${buildSelectorString(
105+
this.selector
106+
)}, cannot call hasClass() on empty Wrapper`
111107
)
112108
}
113109

114110
hasProp(): void {
115111
throwError(
116-
`find did not return ${
117-
this.selectorString
118-
}, cannot call hasProp() on empty Wrapper`
112+
`find did not return ${buildSelectorString(
113+
this.selector
114+
)}, cannot call hasProp() on empty Wrapper`
119115
)
120116
}
121117

122118
hasStyle(): void {
123119
throwError(
124-
`find did not return ${
125-
this.selectorString
126-
}, cannot call hasStyle() on empty Wrapper`
120+
`find did not return ${buildSelectorString(
121+
this.selector
122+
)}, cannot call hasStyle() on empty Wrapper`
127123
)
128124
}
129125

130126
findAll(): void {
131127
throwError(
132-
`find did not return ${
133-
this.selectorString
134-
}, cannot call findAll() on empty Wrapper`
128+
`find did not return ${buildSelectorString(
129+
this.selector
130+
)}, cannot call findAll() on empty Wrapper`
135131
)
136132
}
137133

138134
find(): void {
139135
throwError(
140-
`find did not return ${
141-
this.selectorString
142-
}, cannot call find() on empty Wrapper`
136+
`find did not return ${buildSelectorString(
137+
this.selector
138+
)}, cannot call find() on empty Wrapper`
143139
)
144140
}
145141

146142
html(): void {
147143
throwError(
148-
`find did not return ${
149-
this.selectorString
150-
}, cannot call html() on empty Wrapper`
144+
`find did not return ${buildSelectorString(
145+
this.selector
146+
)}, cannot call html() on empty Wrapper`
151147
)
152148
}
153149

154150
is(): void {
155151
throwError(
156-
`find did not return ${
157-
this.selectorString
158-
}, cannot call is() on empty Wrapper`
152+
`find did not return ${buildSelectorString(
153+
this.selector
154+
)}, cannot call is() on empty Wrapper`
159155
)
160156
}
161157

162158
isEmpty(): void {
163159
throwError(
164-
`find did not return ${
165-
this.selectorString
166-
}, cannot call isEmpty() on empty Wrapper`
160+
`find did not return ${buildSelectorString(
161+
this.selector
162+
)}, cannot call isEmpty() on empty Wrapper`
167163
)
168164
}
169165

170166
isVisible(): void {
171167
throwError(
172-
`find did not return ${
173-
this.selectorString
174-
}, cannot call isVisible() on empty Wrapper`
168+
`find did not return ${buildSelectorString(
169+
this.selector
170+
)}, cannot call isVisible() on empty Wrapper`
175171
)
176172
}
177173

178174
isVueInstance(): void {
179175
throwError(
180-
`find did not return ${
181-
this.selectorString
182-
}, cannot call isVueInstance() on empty Wrapper`
176+
`find did not return ${buildSelectorString(
177+
this.selector
178+
)}, cannot call isVueInstance() on empty Wrapper`
183179
)
184180
}
185181

186182
name(): void {
187183
throwError(
188-
`find did not return ${
189-
this.selectorString
190-
}, cannot call name() on empty Wrapper`
184+
`find did not return ${buildSelectorString(
185+
this.selector
186+
)}, cannot call name() on empty Wrapper`
191187
)
192188
}
193189

194190
props(): void {
195191
throwError(
196-
`find did not return ${
197-
this.selectorString
198-
}, cannot call props() on empty Wrapper`
192+
`find did not return ${buildSelectorString(
193+
this.selector
194+
)}, cannot call props() on empty Wrapper`
199195
)
200196
}
201197

202198
text(): void {
203199
throwError(
204-
`find did not return ${
205-
this.selectorString
206-
}, cannot call text() on empty Wrapper`
200+
`find did not return ${buildSelectorString(
201+
this.selector
202+
)}, cannot call text() on empty Wrapper`
207203
)
208204
}
209205

210206
setComputed(): void {
211207
throwError(
212-
`find did not return ${
213-
this.selectorString
214-
}, cannot call setComputed() on empty Wrapper`
208+
`find did not return ${buildSelectorString(
209+
this.selector
210+
)}, cannot call setComputed() on empty Wrapper`
215211
)
216212
}
217213

218214
setData(): void {
219215
throwError(
220-
`find did not return ${
221-
this.selectorString
222-
}, cannot call setData() on empty Wrapper`
216+
`find did not return ${buildSelectorString(
217+
this.selector
218+
)}, cannot call setData() on empty Wrapper`
223219
)
224220
}
225221

226222
setMethods(): void {
227223
throwError(
228-
`find did not return ${
229-
this.selectorString
230-
}, cannot call setMethods() on empty Wrapper`
224+
`find did not return ${buildSelectorString(
225+
this.selector
226+
)}, cannot call setMethods() on empty Wrapper`
231227
)
232228
}
233229

234230
setProps(): void {
235231
throwError(
236-
`find did not return ${
237-
this.selectorString
238-
}, cannot call setProps() on empty Wrapper`
232+
`find did not return ${buildSelectorString(
233+
this.selector
234+
)}, cannot call setProps() on empty Wrapper`
239235
)
240236
}
241237

242238
setValue(): void {
243239
throwError(
244-
`find did not return ${
245-
this.selectorString
246-
}, cannot call setValue() on empty Wrapper`
240+
`find did not return ${buildSelectorString(
241+
this.selector
242+
)}, cannot call setValue() on empty Wrapper`
247243
)
248244
}
249245

250246
setChecked(): void {
251247
throwError(
252-
`find did not return ${
253-
this.selectorString
254-
}, cannot call setChecked() on empty Wrapper`
248+
`find did not return ${buildSelectorString(
249+
this.selector
250+
)}, cannot call setChecked() on empty Wrapper`
255251
)
256252
}
257253

258254
setSelected(): void {
259255
throwError(
260-
`find did not return ${
261-
this.selectorString
262-
}, cannot call setSelected() on empty Wrapper`
256+
`find did not return ${buildSelectorString(
257+
this.selector
258+
)}, cannot call setSelected() on empty Wrapper`
263259
)
264260
}
265261

266262
trigger(): void {
267263
throwError(
268-
`find did not return ${
269-
this.selectorString
270-
}, cannot call trigger() on empty Wrapper`
264+
`find did not return ${buildSelectorString(
265+
this.selector
266+
)}, cannot call trigger() on empty Wrapper`
271267
)
272268
}
273269

274270
destroy(): void {
275271
throwError(
276-
`find did not return ${
277-
this.selectorString
278-
}, cannot call destroy() on empty Wrapper`
272+
`find did not return ${buildSelectorString(
273+
this.selector
274+
)}, cannot call destroy() on empty Wrapper`
279275
)
280276
}
281277
}

Diff for: test/specs/wrapper/find.spec.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,14 @@ describeWithShallowAndMount('find', mountingMethod => {
363363
const selector = 'pre'
364364
const error = wrapper.find(selector)
365365
expect(error.exists()).to.equal(false)
366-
expect(error.selectorString).to.equal(selector)
366+
expect(error.selector).to.equal(selector)
367367
})
368368

369369
it('returns empty Wrapper with error if no nodes are found when passed a component', () => {
370370
const wrapper = mountingMethod(Component)
371371
const error = wrapper.find(ComponentWithChild)
372372
expect(error.exists()).to.equal(false)
373-
expect(error.selectorString).to.equal('Component')
373+
expect(error.selector).to.equal(ComponentWithChild)
374374
})
375375

376376
it('returns Wrapper of elements matching the ref in options object', () => {
@@ -458,9 +458,10 @@ describeWithShallowAndMount('find', mountingMethod => {
458458

459459
it('returns empty Wrapper with error if no nodes are found via ref in options object', () => {
460460
const wrapper = mountingMethod(Component)
461-
const error = wrapper.find({ ref: 'foo' })
461+
const selector = { ref: 'foo' }
462+
const error = wrapper.find(selector)
462463
expect(error.exists()).to.equal(false)
463-
expect(error.selectorString).to.equal('ref="foo"')
464+
expect(error.selector).to.equal(selector)
464465
})
465466

466467
it('returns Wrapper matching component that has no name property', () => {

0 commit comments

Comments
 (0)