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

-added a test to check the error from the issue 1820 #1832

Closed
wants to merge 6 commits into from
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.
Jump to
Jump to file
Failed to load files.
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