Skip to content

Commit 176d853

Browse files
refactor: cleanup tests
1 parent 671b982 commit 176d853

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

test/specs/wrapper/find.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ describeWithShallowAndMount('find', mountingMethod => {
152152
.with.property('message', message)
153153
})
154154

155+
it('throws an error if findComponent is chained off a DOM element', () => {
156+
const wrapper = mountingMethod(ComponentWithChild)
157+
const message =
158+
'[vue-test-utils]: You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
159+
const fn = () => wrapper.find('span').findComponent('#foo')
160+
expect(fn)
161+
.to.throw()
162+
.with.property('message', message)
163+
})
164+
155165
itSkipIf(isRunningPhantomJS, 'returns Wrapper of class component', () => {
156166
const TestComponent = {
157167
template: `

test/specs/wrapper/findAll.spec.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,32 @@ describeWithShallowAndMount('findAll', mountingMethod => {
145145
expect(componentArr.length).to.equal(1)
146146
})
147147

148-
it('returns an array of VueWrappers of Vue Components matching componentusing findAllComponents', () => {
148+
it('returns an array of VueWrappers of Vue Components matching components using findAllComponents', () => {
149149
const wrapper = mountingMethod(ComponentWithChild)
150150
const componentArr = wrapper.findAllComponents(Component)
151151
expect(componentArr.length).to.equal(1)
152152
})
153153

154-
it('throws an error if findComponent selector is a CSS selector', () => {
154+
it('throws an error if findAllComponents selector is a CSS selector', () => {
155155
const wrapper = mountingMethod(Component)
156156
const message =
157-
'[vue-test-utils]: findAllComponent requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
157+
'[vue-test-utils]: findAllComponents requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
158158
const fn = () => wrapper.findAllComponents('#foo')
159159
expect(fn)
160160
.to.throw()
161161
.with.property('message', message)
162162
})
163163

164+
it('throws an error if chaining findAllComponents off a DOM element', () => {
165+
const wrapper = mountingMethod(ComponentWithChild)
166+
const message =
167+
'[vue-test-utils]: You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.'
168+
const fn = () => wrapper.find('span').findAllComponents('#foo')
169+
expect(fn)
170+
.to.throw()
171+
.with.property('message', message)
172+
})
173+
164174
it('returns correct number of Vue Wrapper when component has a v-for', () => {
165175
const items = [{ id: 1 }, { id: 2 }, { id: 3 }]
166176
const wrapper = mountingMethod(ComponentWithVFor, { propsData: { items } })

0 commit comments

Comments
 (0)