Skip to content

Commit

Permalink
chore: Remove selectorString from ErrorWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
winniehell committed Jun 5, 2019
1 parent b87e922 commit 70ac83a
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 99 deletions.
188 changes: 93 additions & 95 deletions packages/test-utils/src/error-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,56 @@ const buildSelectorString = (selector: Selector) => {

export default class ErrorWrapper implements BaseWrapper {
selector: Selector
selectorString: string

constructor(selector: Selector) {
this.selector = selector
this.selectorString = buildSelectorString(selector)
}

at(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call at() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call at() on empty Wrapper`
)
}

attributes(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call attributes() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call attributes() on empty Wrapper`
)
}

classes(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call classes() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call classes() on empty Wrapper`
)
}

contains(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call contains() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call contains() on empty Wrapper`
)
}

emitted(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call emitted() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call emitted() on empty Wrapper`
)
}

emittedByOrder(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call emittedByOrder() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call emittedByOrder() on empty Wrapper`
)
}

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

filter(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call filter() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call filter() on empty Wrapper`
)
}

visible(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call visible() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call visible() on empty Wrapper`
)
}

hasAttribute(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call hasAttribute() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call hasAttribute() on empty Wrapper`
)
}

hasClass(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call hasClass() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call hasClass() on empty Wrapper`
)
}

hasProp(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call hasProp() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call hasProp() on empty Wrapper`
)
}

hasStyle(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call hasStyle() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call hasStyle() on empty Wrapper`
)
}

findAll(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call findAll() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call findAll() on empty Wrapper`
)
}

find(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call find() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call find() on empty Wrapper`
)
}

html(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call html() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call html() on empty Wrapper`
)
}

is(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call is() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call is() on empty Wrapper`
)
}

isEmpty(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call isEmpty() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call isEmpty() on empty Wrapper`
)
}

isVisible(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call isVisible() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call isVisible() on empty Wrapper`
)
}

isVueInstance(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call isVueInstance() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call isVueInstance() on empty Wrapper`
)
}

name(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call name() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call name() on empty Wrapper`
)
}

props(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call props() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call props() on empty Wrapper`
)
}

text(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call text() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call text() on empty Wrapper`
)
}

setComputed(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setComputed() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setComputed() on empty Wrapper`
)
}

setData(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setData() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setData() on empty Wrapper`
)
}

setMethods(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setMethods() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setMethods() on empty Wrapper`
)
}

setProps(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setProps() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setProps() on empty Wrapper`
)
}

setValue(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setValue() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setValue() on empty Wrapper`
)
}

setChecked(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setChecked() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setChecked() on empty Wrapper`
)
}

setSelected(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call setSelected() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call setSelected() on empty Wrapper`
)
}

trigger(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call trigger() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call trigger() on empty Wrapper`
)
}

destroy(): void {
throwError(
`find did not return ${
this.selectorString
}, cannot call destroy() on empty Wrapper`
`find did not return ${buildSelectorString(
this.selector
)}, cannot call destroy() on empty Wrapper`
)
}
}
9 changes: 5 additions & 4 deletions test/specs/wrapper/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,14 @@ describeWithShallowAndMount('find', mountingMethod => {
const selector = 'pre'
const error = wrapper.find(selector)
expect(error.exists()).to.equal(false)
expect(error.selectorString).to.equal(selector)
expect(error.selector.value).to.equal(selector)
})

it('returns empty Wrapper with error if no nodes are found when passed a component', () => {
const wrapper = mountingMethod(Component)
const error = wrapper.find(ComponentWithChild)
expect(error.exists()).to.equal(false)
expect(error.selectorString).to.equal('Component')
expect(error.selector.value).to.equal(ComponentWithChild)
})

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

it('returns empty Wrapper with error if no nodes are found via ref in options object', () => {
const wrapper = mountingMethod(Component)
const error = wrapper.find({ ref: 'foo' })
const selector = { ref: 'foo' }
const error = wrapper.find(selector)
expect(error.exists()).to.equal(false)
expect(error.selectorString).to.equal('ref="foo"')
expect(error.selector.value).to.equal(selector)
})

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

0 comments on commit 70ac83a

Please # to comment.