From 1dfd60b8ff9351b003e993ca08cd1977180e7172 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 1 Jul 2019 18:31:35 +0200 Subject: [PATCH] test(view): test named views --- __tests__/router-view.spec.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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
"`) + }) }) -- 2.47.2