Skip to content

Commit dc3d1f6

Browse files
committed
chore: Build selector string in ErrorWrapper
1 parent bd5d8d6 commit dc3d1f6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/test-utils/src/error-wrapper.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
// @flow
22

33
import { throwError } from 'shared/util'
4+
import { REF_SELECTOR } from 'shared/consts'
5+
6+
const buildSelectorString = (selector: Selector) => {
7+
if (selector.type === REF_SELECTOR) {
8+
return `ref="${selector.value.ref}"`
9+
}
10+
11+
if (typeof selector.value === 'string') {
12+
return selector.value
13+
}
14+
15+
return 'Component'
16+
}
417

518
export default class ErrorWrapper implements BaseWrapper {
619
selectorString: string
720

8-
constructor(selectorString: string) {
9-
this.selectorString = selectorString
21+
constructor(selector: Selector) {
22+
this.selectorString = buildSelectorString(selector)
1023
}
1124

1225
at(): void {

packages/test-utils/src/wrapper.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,7 @@ export default class Wrapper implements BaseWrapper {
193193
const node = find(this.rootNode, this.vm, selector)[0]
194194

195195
if (!node) {
196-
if (selector.type === REF_SELECTOR) {
197-
return new ErrorWrapper(`ref="${selector.value.ref}"`)
198-
}
199-
return new ErrorWrapper(
200-
typeof selector.value === 'string' ? selector.value : 'Component'
201-
)
196+
return new ErrorWrapper(selector)
202197
}
203198

204199
return createWrapper(node, this.options)

0 commit comments

Comments
 (0)