From 667bc80af99870f1b1c71818990e0e9f8a86cee0 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 24 Jul 2020 10:42:22 +0200 Subject: [PATCH] test(router-view): test v-slot --- __tests__/RouterView.spec.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/__tests__/RouterView.spec.ts b/__tests__/RouterView.spec.ts index 2f2ba4c3..812d5c24 100644 --- a/__tests__/RouterView.spec.ts +++ b/__tests__/RouterView.spec.ts @@ -29,7 +29,7 @@ const props = { default: false } const routes = createRoutes({ root: { fullPath: '/', - name: undefined, + name: 'home', path: '/', query: {}, params: {}, @@ -330,6 +330,7 @@ describe('RouterView', () => { expect(wrapper.html()).toBe(`
Home
`) expect('can no longer be used directly inside').not.toHaveBeenWarned() }) + it('warns if KeepAlive wraps a RouterView', async () => { const route = createMockedRoute(routes.root) const wrapper = await mount( @@ -393,6 +394,33 @@ describe('RouterView', () => { }) }) + describe('v-slot', () => { + async function factory( + initialRoute: RouteLocationNormalizedLoose, + propsData: any = {} + ) { + const route = createMockedRoute(initialRoute) + const wrapper = await mount(RouterView, { + propsData, + provide: route.provides, + components: { RouterView }, + slots: { + default: ` + {{ route.name }} + + `, + }, + }) + + return { route, wrapper } + } + + it('passes a Component and route', async () => { + const { wrapper } = await factory(routes.root) + expect(wrapper.html()).toBe(`home
Home
`) + }) + }) + describe('KeepAlive', () => { async function factory( initialRoute: RouteLocationNormalizedLoose, -- 2.47.3