From 8b428b465154b0a1fd1abb1edd942c88cb7fceeb Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 20 Nov 2023 23:13:14 +0000 Subject: [PATCH] style: lint --- src/vitest-environment-nuxt/runtime/mount.ts | 127 ++++++++++--------- 1 file changed, 66 insertions(+), 61 deletions(-) diff --git a/src/vitest-environment-nuxt/runtime/mount.ts b/src/vitest-environment-nuxt/runtime/mount.ts index 6e0416afd..893e9d022 100644 --- a/src/vitest-environment-nuxt/runtime/mount.ts +++ b/src/vitest-environment-nuxt/runtime/mount.ts @@ -71,69 +71,74 @@ export async function mountSuspended( } } - return new Promise> & { setupState: any }>(resolve => { - const vm = mount( - { - setup: (props: Record, ctx: SetupContext) => { - setupContext = ctx - return NuxtRoot.setup(props, { - ...ctx, - expose: () => {}, - }) - }, - render: (renderContext: any) => - h( - Suspense, - { - onResolve: () => - nextTick().then(() => { - ;(vm as any).setupState = setupState - resolve(vm as any) - }), - }, - { - default: () => - h({ - async setup() { - const router = useRouter() - await router.replace(route) + return new Promise> & { setupState: any }>( + resolve => { + const vm = mount( + { + setup: (props: Record, ctx: SetupContext) => { + setupContext = ctx + return NuxtRoot.setup(props, { + ...ctx, + expose: () => {}, + }) + }, + render: (renderContext: any) => + h( + Suspense, + { + onResolve: () => + nextTick().then(() => { + ;(vm as any).setupState = setupState + resolve(vm as any) + }), + }, + { + default: () => + h({ + async setup() { + const router = useRouter() + await router.replace(route) - // Proxy top-level setup/render context so test wrapper resolves child component - const clonedComponent = { - ...component, - render: render - ? (_ctx: any, ...args: any[]) => { - // add all _ctx properties to renderContext - // the renderContext must remain intact, otherwise the emits don't work - for (const key in _ctx) { - renderContext[key] = _ctx[key] + // Proxy top-level setup/render context so test wrapper resolves child component + const clonedComponent = { + ...component, + render: render + ? (_ctx: any, ...args: any[]) => { + // add all _ctx properties to renderContext + // the renderContext must remain intact, otherwise the emits don't work + for (const key in _ctx) { + renderContext[key] = _ctx[key] + } + return render.apply(_ctx, [ + renderContext, + ...args, + ]) } - return render.apply(_ctx, [renderContext, ...args]) - } - : undefined, - setup: setup - ? (props: Record) => - wrappedSetup(props, setupContext) - : undefined, - } + : undefined, + setup: setup + ? (props: Record) => + wrappedSetup(props, setupContext) + : undefined, + } - return () => - h(clonedComponent, { ...props, ...attrs }, slots) - }, - }), - } - ), - }, - defu(_options, { - slots, - global: { - config: { - globalProperties: vueApp.config.globalProperties, - }, - provide: vueApp._context.provides, - components: { RouterLink }, + return () => + h(clonedComponent, { ...props, ...attrs }, slots) + }, + }), + } + ), }, - } satisfies ComponentMountingOptions) as ComponentMountingOptions - ) - }) + defu(_options, { + slots, + global: { + config: { + globalProperties: vueApp.config.globalProperties, + }, + provide: vueApp._context.provides, + components: { RouterLink }, + }, + } satisfies ComponentMountingOptions) as ComponentMountingOptions + ) + } + ) }