File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,19 @@ import {
4
4
FUNCTIONAL_OPTIONS
5
5
} from 'shared/consts'
6
6
import { isConstructor } from 'shared/validators'
7
- import { capitalize } from 'shared/util'
7
+ import { capitalize , camelize } from 'shared/util'
8
8
9
9
function vmMatchesName ( vm , name ) {
10
+ console . log ( name )
11
+ console . log ( vm . $options . name )
10
12
return (
11
13
! ! name && (
12
- vm . name === name ||
14
+ vm . name === name ||
13
15
( vm . $options && vm . $options . name === name ) ||
14
16
vm . name === capitalize ( name ) ||
15
- vm . $options && vm . $options . name === capitalize ( name )
17
+ vm . $options && vm . $options . name === capitalize ( name ) ||
18
+ vm . $options && vm . $options . name && vm . $options . name === capitalize ( camelize ( name ) ) ||
19
+ vm . $options && vm . $options . name && capitalize ( camelize ( vm . $options . name ) ) === name
16
20
)
17
21
)
18
22
}
Original file line number Diff line number Diff line change @@ -440,6 +440,24 @@ describeWithShallowAndMount('find', mountingMethod => {
440
440
expect ( wrapper . find ( { name : 'camelCase' } ) . name ( ) ) . to . equal ( 'CamelCase' )
441
441
} )
442
442
443
+ it ( 'returns a Wrapper matching a kebab-case name option and a Pascal Case component name ' , ( ) => {
444
+ const component = {
445
+ name : 'CamelCase' ,
446
+ render : h => h ( 'div' )
447
+ }
448
+ const wrapper = mountingMethod ( component )
449
+ expect ( wrapper . find ( { name : 'camel-case' } ) . name ( ) ) . to . equal ( 'CamelCase' )
450
+ } )
451
+
452
+ it ( 'returns a Wrapper matching a Pascal Case name option and a kebab-casecomponent name ' , ( ) => {
453
+ const component = {
454
+ name : 'camel-case' ,
455
+ render : h => h ( 'div' )
456
+ }
457
+ const wrapper = mountingMethod ( component )
458
+ expect ( wrapper . find ( { name : 'CamelCase' } ) . name ( ) ) . to . equal ( 'camel-case' )
459
+ } )
460
+
443
461
it ( 'returns Wrapper of Vue Component matching the ref in options object' , ( ) => {
444
462
const wrapper = mountingMethod ( ComponentWithChild )
445
463
expect ( wrapper . find ( { ref : 'child' } ) . isVueInstance ( ) ) . to . equal ( true )
@@ -450,7 +468,7 @@ describeWithShallowAndMount('find', mountingMethod => {
450
468
const wrapper = mountingMethod ( compiled )
451
469
const a = wrapper . find ( 'a' )
452
470
const message =
453
- '[vue-test-utils]: $ref selectors can only be used on Vue component wrappers'
471
+ '[vue-test-utils]: $ref selectors can used on Vue component wrappers'
454
472
const fn = ( ) => a . find ( { ref : 'foo' } )
455
473
expect ( fn )
456
474
. to . throw ( )
You can’t perform that action at this time.
0 commit comments