Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1813 #1817

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/test-utils/src/matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function vmMatchesName(vm, name) {
// We want to mirror how Vue resolves component names in SFCs:
// For example, <test-component />, <TestComponent /> and `<testComponent />
// all resolve to the same component
const componentName = (vm.$options && vm.$options.name) || ''
const componentName = vm.name || (vm.$options && vm.$options.name) || ''
return (
!!name &&
(componentName === name ||
Expand Down Expand Up @@ -56,13 +56,7 @@ export function matches(node, selector) {
return element && element.matches && element.matches(selector.value)
}

const isFunctionalSelector = isConstructor(selector.value)
? selector.value.options.functional
: selector.value.functional

const componentInstance = isFunctionalSelector
? node[FUNCTIONAL_OPTIONS]
: node.child
const componentInstance = node[FUNCTIONAL_OPTIONS] || node.child
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the line you removed was for back compat. You might need to skip the failing test. Are you able to update the PR and fix the failing test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I just skip this test for vue < 2.3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I find no way to throw exception in this case

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's probably fine, go for it. I think most people will be on at least 2.5 by now.


if (!componentInstance) {
return false
Expand Down
22 changes: 22 additions & 0 deletions test/specs/wrapper/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,28 @@ describeWithShallowAndMount('find', mountingMethod => {
}
})

itSkipIf(
vueVersion < 2.3,
'returns functional component with name by name',
() => {
const TestFunctionalComponent = {
render: h => h('div'),
functional: true,
name: 'test-functional-component'
}
const TestComponent = {
template: '<div><test-functional-component /></div>',
components: {
TestFunctionalComponent
}
}
const wrapper = mountingMethod(TestComponent)
expect(
wrapper.find({ name: 'test-functional-component' }).exists()
).toEqual(true)
}
)

it('returns extended functional component', () => {
const TestFunctionalComponent = Vue.extend({
render: h => h('div'),
Expand Down