Skip to content

Commit e7bc6a1

Browse files
38elementseddyerburgh
authored andcommitted
test: name in options object (vuejs#348)
1 parent 65a22c8 commit e7bc6a1

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/en/api/selectors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ expect(wrapper.is(Foo)).toBe(true)
4444

4545
### Name
4646

47-
Using a find option object, `vue-test-utils` allows for selecting elements by `name` on wrapper components.
47+
Using a find option object, `vue-test-utils` allows for selecting elements by a `name` of component on wrapper components.
4848

4949
```js
5050
const buttonWrapper = wrapper.find({ name: 'my-button' })

test/unit/specs/mount/Wrapper/find.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ describe('find', () => {
238238
expect(wrapper.find(TestComponent).isVueComponent).to.equal(true)
239239
})
240240

241+
it('returns a Wrapper matching a component name in options object', () => {
242+
const wrapper = mount(ComponentWithChild)
243+
expect(wrapper.find({ name: 'component' }).name()).to.equal('component')
244+
})
245+
241246
it('returns Wrapper of Vue Component matching the ref in options object', () => {
242247
const wrapper = mount(ComponentWithChild)
243248
expect(wrapper.find({ ref: 'child' }).isVueComponent).to.equal(true)

test/unit/specs/mount/Wrapper/findAll.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ describe('findAll', () => {
220220
expect(preArray.wrappers).to.deep.equal([])
221221
})
222222

223+
it('returns an array of Wrapper of elements matching a component name in options object', () => {
224+
const wrapper = mount(ComponentWithChild)
225+
const wrapperArray = wrapper.findAll({ name: 'component' })
226+
expect(wrapperArray.at(0).name()).to.equal('component')
227+
expect(wrapperArray.length).to.equal(1)
228+
})
229+
223230
it('returns an array of Wrapper of elements matching the ref in options object', () => {
224231
const compiled = compileToFunctions('<div><div ref="foo" /></div>')
225232
const wrapper = mount(compiled)

0 commit comments

Comments
 (0)