Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/test-utils/src/matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ export function matches(node, selector) {
return element && element.matches && element.matches(selector.value)
}

const componentInstance = node[FUNCTIONAL_OPTIONS] || node.child
// ignore the functional component if its a RouterView
// Find a good explanation comment why tahts the case, please help!
const componentInstance =
node[FUNCTIONAL_OPTIONS] && node[FUNCTIONAL_OPTIONS].name === 'RouterView'
? node.child
: node[FUNCTIONAL_OPTIONS] || node.child

if (!componentInstance) {
return false
Expand Down
35 changes: 35 additions & 0 deletions test/specs/wrapper/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
isRunningChrome
} from '~resources/utils'
import { itDoNotRunIf, itSkipIf } from 'conditional-specs'
import VueRouter from 'vue-router'

describeWithShallowAndMount('find', mountingMethod => {
it('returns a Wrapper matching tag selector passed', () => {
Expand Down Expand Up @@ -279,6 +280,40 @@ describeWithShallowAndMount('find', mountingMethod => {
}
)

itDoNotRunIf(
mountingMethod.name === 'shallowMount',
'returns a VueWrapper using a <router-view/> component',
async () => {
const localVue = createLocalVue()
localVue.use(VueRouter)
const TestComponentToFind = {
render: h => h('div'),
name: 'test-component-to-find'
}
const routes = [
{
path: '/a/b',
name: 'ab',
component: TestComponentToFind
}
]
const router = new VueRouter({ routes })
const wrapper = mountingMethod(
{
template: '<router-view/>'
},
{
localVue,
router
}
)

await router.push('/a/b')

expect(wrapper.findComponent(TestComponentToFind).exists()).toBe(true)
}
)

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