Skip to content

Commit 82bd743

Browse files
committed
fix: do not remove hyphen in component names
1 parent 83ee6c1 commit 82bd743

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/test-utils/src/matches.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {
66
import { isConstructor } from 'shared/validators'
77

88
function vmMatchesName(vm, name) {
9-
const normalize = (name = '') => name.replace(/-/gi, '').toLowerCase()
10-
const normalizedName = normalize(name)
9+
const lc = (name = '') => name.toLowerCase()
10+
const lowerCaseName = lc(name)
1111
return (
1212
!!name &&
13-
(normalize(vm.name) === normalizedName ||
14-
(vm.$options && normalize(vm.$options.name) === normalizedName))
13+
(lc(vm.name) === lowerCaseName ||
14+
(vm.$options && lc(vm.$options.name) === lowerCaseName))
1515
)
1616
}
1717

test/specs/wrapper/find.spec.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,18 +431,20 @@ describeWithShallowAndMount('find', mountingMethod => {
431431
)
432432
})
433433

434-
it('returns a Wrapper matching a component pascal case name in options object', () => {
434+
it('returns a Wrapper matching a component camel case name in options object', () => {
435435
const wrapper = mountingMethod(ComponentWithChild)
436-
expect(wrapper.find({ name: 'TestComponent' }).name()).to.equal(
436+
expect(wrapper.find({ name: 'test-Component' }).name()).to.equal(
437437
'test-component'
438438
)
439439
})
440440

441-
it('returns a Wrapper matching a component camel case name in options object', () => {
442-
const wrapper = mountingMethod(ComponentWithChild)
443-
expect(wrapper.find({ name: 'testComponent' }).name()).to.equal(
444-
'test-component'
445-
)
441+
it('returns a Wrapper matching a name disregarding case in options object', () => {
442+
const component = {
443+
name: 'CamelCase',
444+
render: h => h('div')
445+
}
446+
const wrapper = mountingMethod(component)
447+
expect(wrapper.find({ name: 'camelCase' }).name()).to.equal('CamelCase')
446448
})
447449

448450
it('returns Wrapper of Vue Component matching the ref in options object', () => {

0 commit comments

Comments
 (0)