File tree 3 files changed +13
-1
lines changed
test/unit/specs/mount/Wrapper
3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ expect(wrapper.is(Foo)).toBe(true)
44
44
45
45
### Name
46
46
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.
48
48
49
49
``` js
50
50
const buttonWrapper = wrapper .find ({ name: ' my-button' })
Original file line number Diff line number Diff line change @@ -238,6 +238,11 @@ describe('find', () => {
238
238
expect ( wrapper . find ( TestComponent ) . isVueComponent ) . to . equal ( true )
239
239
} )
240
240
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
+
241
246
it ( 'returns Wrapper of Vue Component matching the ref in options object' , ( ) => {
242
247
const wrapper = mount ( ComponentWithChild )
243
248
expect ( wrapper . find ( { ref : 'child' } ) . isVueComponent ) . to . equal ( true )
Original file line number Diff line number Diff line change @@ -220,6 +220,13 @@ describe('findAll', () => {
220
220
expect ( preArray . wrappers ) . to . deep . equal ( [ ] )
221
221
} )
222
222
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
+
223
230
it ( 'returns an array of Wrapper of elements matching the ref in options object' , ( ) => {
224
231
const compiled = compileToFunctions ( '<div><div ref="foo" /></div>' )
225
232
const wrapper = mount ( compiled )
You can’t perform that action at this time.
0 commit comments