Skip to content

Commit 70ac83a

Browse files
committed
chore: Remove selectorString from ErrorWrapper
1 parent b87e922 commit 70ac83a

File tree

2 files changed

+98
-99
lines changed

2 files changed

+98
-99
lines changed

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

+93-95
Original file line numberDiff line numberDiff line change
@@ -17,58 +17,56 @@ const buildSelectorString = (selector: Selector) => {
1717

1818
export default class ErrorWrapper implements BaseWrapper {
1919
selector: Selector
20-
selectorString: string
2120

2221
constructor(selector: Selector) {
2322
this.selector = selector
24-
this.selectorString = buildSelectorString(selector)
2523
}
2624

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

3533
attributes(): void {
3634
throwError(
37-
`find did not return ${
38-
this.selectorString
39-
}, cannot call attributes() on empty Wrapper`
35+
`find did not return ${buildSelectorString(
36+
this.selector
37+
)}, cannot call attributes() on empty Wrapper`
4038
)
4139
}
4240

4341
classes(): void {
4442
throwError(
45-
`find did not return ${
46-
this.selectorString
47-
}, cannot call classes() on empty Wrapper`
43+
`find did not return ${buildSelectorString(
44+
this.selector
45+
)}, cannot call classes() on empty Wrapper`
4846
)
4947
}
5048

5149
contains(): void {
5250
throwError(
53-
`find did not return ${
54-
this.selectorString
55-
}, cannot call contains() on empty Wrapper`
51+
`find did not return ${buildSelectorString(
52+
this.selector
53+
)}, cannot call contains() on empty Wrapper`
5654
)
5755
}
5856

5957
emitted(): void {
6058
throwError(
61-
`find did not return ${
62-
this.selectorString
63-
}, cannot call emitted() on empty Wrapper`
59+
`find did not return ${buildSelectorString(
60+
this.selector
61+
)}, cannot call emitted() on empty Wrapper`
6462
)
6563
}
6664

6765
emittedByOrder(): void {
6866
throwError(
69-
`find did not return ${
70-
this.selectorString
71-
}, cannot call emittedByOrder() on empty Wrapper`
67+
`find did not return ${buildSelectorString(
68+
this.selector
69+
)}, cannot call emittedByOrder() on empty Wrapper`
7270
)
7371
}
7472

@@ -78,201 +76,201 @@ export default class ErrorWrapper implements BaseWrapper {
7876

7977
filter(): void {
8078
throwError(
81-
`find did not return ${
82-
this.selectorString
83-
}, cannot call filter() on empty Wrapper`
79+
`find did not return ${buildSelectorString(
80+
this.selector
81+
)}, cannot call filter() on empty Wrapper`
8482
)
8583
}
8684

8785
visible(): void {
8886
throwError(
89-
`find did not return ${
90-
this.selectorString
91-
}, cannot call visible() on empty Wrapper`
87+
`find did not return ${buildSelectorString(
88+
this.selector
89+
)}, cannot call visible() on empty Wrapper`
9290
)
9391
}
9492

9593
hasAttribute(): void {
9694
throwError(
97-
`find did not return ${
98-
this.selectorString
99-
}, cannot call hasAttribute() on empty Wrapper`
95+
`find did not return ${buildSelectorString(
96+
this.selector
97+
)}, cannot call hasAttribute() on empty Wrapper`
10098
)
10199
}
102100

103101
hasClass(): void {
104102
throwError(
105-
`find did not return ${
106-
this.selectorString
107-
}, cannot call hasClass() on empty Wrapper`
103+
`find did not return ${buildSelectorString(
104+
this.selector
105+
)}, cannot call hasClass() on empty Wrapper`
108106
)
109107
}
110108

111109
hasProp(): void {
112110
throwError(
113-
`find did not return ${
114-
this.selectorString
115-
}, cannot call hasProp() on empty Wrapper`
111+
`find did not return ${buildSelectorString(
112+
this.selector
113+
)}, cannot call hasProp() on empty Wrapper`
116114
)
117115
}
118116

119117
hasStyle(): void {
120118
throwError(
121-
`find did not return ${
122-
this.selectorString
123-
}, cannot call hasStyle() on empty Wrapper`
119+
`find did not return ${buildSelectorString(
120+
this.selector
121+
)}, cannot call hasStyle() on empty Wrapper`
124122
)
125123
}
126124

127125
findAll(): void {
128126
throwError(
129-
`find did not return ${
130-
this.selectorString
131-
}, cannot call findAll() on empty Wrapper`
127+
`find did not return ${buildSelectorString(
128+
this.selector
129+
)}, cannot call findAll() on empty Wrapper`
132130
)
133131
}
134132

135133
find(): void {
136134
throwError(
137-
`find did not return ${
138-
this.selectorString
139-
}, cannot call find() on empty Wrapper`
135+
`find did not return ${buildSelectorString(
136+
this.selector
137+
)}, cannot call find() on empty Wrapper`
140138
)
141139
}
142140

143141
html(): void {
144142
throwError(
145-
`find did not return ${
146-
this.selectorString
147-
}, cannot call html() on empty Wrapper`
143+
`find did not return ${buildSelectorString(
144+
this.selector
145+
)}, cannot call html() on empty Wrapper`
148146
)
149147
}
150148

151149
is(): void {
152150
throwError(
153-
`find did not return ${
154-
this.selectorString
155-
}, cannot call is() on empty Wrapper`
151+
`find did not return ${buildSelectorString(
152+
this.selector
153+
)}, cannot call is() on empty Wrapper`
156154
)
157155
}
158156

159157
isEmpty(): void {
160158
throwError(
161-
`find did not return ${
162-
this.selectorString
163-
}, cannot call isEmpty() on empty Wrapper`
159+
`find did not return ${buildSelectorString(
160+
this.selector
161+
)}, cannot call isEmpty() on empty Wrapper`
164162
)
165163
}
166164

167165
isVisible(): void {
168166
throwError(
169-
`find did not return ${
170-
this.selectorString
171-
}, cannot call isVisible() on empty Wrapper`
167+
`find did not return ${buildSelectorString(
168+
this.selector
169+
)}, cannot call isVisible() on empty Wrapper`
172170
)
173171
}
174172

175173
isVueInstance(): void {
176174
throwError(
177-
`find did not return ${
178-
this.selectorString
179-
}, cannot call isVueInstance() on empty Wrapper`
175+
`find did not return ${buildSelectorString(
176+
this.selector
177+
)}, cannot call isVueInstance() on empty Wrapper`
180178
)
181179
}
182180

183181
name(): void {
184182
throwError(
185-
`find did not return ${
186-
this.selectorString
187-
}, cannot call name() on empty Wrapper`
183+
`find did not return ${buildSelectorString(
184+
this.selector
185+
)}, cannot call name() on empty Wrapper`
188186
)
189187
}
190188

191189
props(): void {
192190
throwError(
193-
`find did not return ${
194-
this.selectorString
195-
}, cannot call props() on empty Wrapper`
191+
`find did not return ${buildSelectorString(
192+
this.selector
193+
)}, cannot call props() on empty Wrapper`
196194
)
197195
}
198196

199197
text(): void {
200198
throwError(
201-
`find did not return ${
202-
this.selectorString
203-
}, cannot call text() on empty Wrapper`
199+
`find did not return ${buildSelectorString(
200+
this.selector
201+
)}, cannot call text() on empty Wrapper`
204202
)
205203
}
206204

207205
setComputed(): void {
208206
throwError(
209-
`find did not return ${
210-
this.selectorString
211-
}, cannot call setComputed() on empty Wrapper`
207+
`find did not return ${buildSelectorString(
208+
this.selector
209+
)}, cannot call setComputed() on empty Wrapper`
212210
)
213211
}
214212

215213
setData(): void {
216214
throwError(
217-
`find did not return ${
218-
this.selectorString
219-
}, cannot call setData() on empty Wrapper`
215+
`find did not return ${buildSelectorString(
216+
this.selector
217+
)}, cannot call setData() on empty Wrapper`
220218
)
221219
}
222220

223221
setMethods(): void {
224222
throwError(
225-
`find did not return ${
226-
this.selectorString
227-
}, cannot call setMethods() on empty Wrapper`
223+
`find did not return ${buildSelectorString(
224+
this.selector
225+
)}, cannot call setMethods() on empty Wrapper`
228226
)
229227
}
230228

231229
setProps(): void {
232230
throwError(
233-
`find did not return ${
234-
this.selectorString
235-
}, cannot call setProps() on empty Wrapper`
231+
`find did not return ${buildSelectorString(
232+
this.selector
233+
)}, cannot call setProps() on empty Wrapper`
236234
)
237235
}
238236

239237
setValue(): void {
240238
throwError(
241-
`find did not return ${
242-
this.selectorString
243-
}, cannot call setValue() on empty Wrapper`
239+
`find did not return ${buildSelectorString(
240+
this.selector
241+
)}, cannot call setValue() on empty Wrapper`
244242
)
245243
}
246244

247245
setChecked(): void {
248246
throwError(
249-
`find did not return ${
250-
this.selectorString
251-
}, cannot call setChecked() on empty Wrapper`
247+
`find did not return ${buildSelectorString(
248+
this.selector
249+
)}, cannot call setChecked() on empty Wrapper`
252250
)
253251
}
254252

255253
setSelected(): void {
256254
throwError(
257-
`find did not return ${
258-
this.selectorString
259-
}, cannot call setSelected() on empty Wrapper`
255+
`find did not return ${buildSelectorString(
256+
this.selector
257+
)}, cannot call setSelected() on empty Wrapper`
260258
)
261259
}
262260

263261
trigger(): void {
264262
throwError(
265-
`find did not return ${
266-
this.selectorString
267-
}, cannot call trigger() on empty Wrapper`
263+
`find did not return ${buildSelectorString(
264+
this.selector
265+
)}, cannot call trigger() on empty Wrapper`
268266
)
269267
}
270268

271269
destroy(): void {
272270
throwError(
273-
`find did not return ${
274-
this.selectorString
275-
}, cannot call destroy() on empty Wrapper`
271+
`find did not return ${buildSelectorString(
272+
this.selector
273+
)}, cannot call destroy() on empty Wrapper`
276274
)
277275
}
278276
}

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.value).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.value).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.value).to.equal(selector)
464465
})
465466

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

0 commit comments

Comments
 (0)