From: Eduardo San Martin Morote Date: Mon, 1 Jul 2019 16:31:35 +0000 (+0200) Subject: test(view): test named views X-Git-Tag: v4.0.0-alpha.0~318 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dfd60b8ff9351b003e993ca08cd1977180e7172;p=thirdparty%2Fvuejs%2Frouter.git test(view): test named views --- diff --git a/__tests__/router-view.spec.js b/__tests__/router-view.spec.js index 1c1ea358..0e01a284 100644 --- a/__tests__/router-view.spec.js +++ b/__tests__/router-view.spec.js @@ -22,6 +22,16 @@ const routes = { // meta: {}, matched: [{ components: { default: components.Home }, path: '/' }], }, + named: { + fullPath: '/', + name: undefined, + path: '/', + query: {}, + params: {}, + hash: '', + // meta: {}, + matched: [{ components: { foo: components.Foo }, path: '/' }], + }, } describe('RouterView', () => { @@ -33,10 +43,15 @@ describe('RouterView', () => { /** * * @param {RouteLocationNormalized} $route + * @param {Object} [props] */ - function factory($route) { + function factory($route, props = {}) { // @ts-ignore cannot mount functional component? const wrapper = mount(RouterView, { + context: { + // https://github.com/vuejs/vue-test-utils/issues/918 + props, + }, mocks: { $route }, }) return wrapper @@ -46,4 +61,9 @@ describe('RouterView', () => { const wrapper = factory(routes.root) expect(wrapper.html()).toMatchInlineSnapshot(`"
Home
"`) }) + + it('displays named views', async () => { + const wrapper = factory(routes.named, { name: 'foo' }) + expect(wrapper.html()).toMatchInlineSnapshot(`"
Foo
"`) + }) })