import { describe, expect, it } from 'vitest' import type { Plugin } from 'vite' import type { Component } from '@nuxt/schema' import { islandsTransform } from '../src/components/islandsTransform' import { normalizeLineEndings } from './utils' const getComponents = () => [{ filePath: '/root/hello.server.vue', mode: 'server', pascalName: 'HelloWorld', island: true, kebabName: 'hello-world', chunkName: 'components/hello-world', export: 'default', shortPath: '', prefetch: false, preload: false }] as Component[] const pluginVite = islandsTransform.raw({ getComponents }, { framework: 'vite' }) as Plugin const viteTransform = async (source: string, id: string) => { const result = await (pluginVite.transform! as Function)(source, id) return typeof result === 'string' ? result : result?.code } describe('islandTransform - server and island components', () => { describe('slots', () => { it('expect slot transform to match inline snapshot', async () => { const result = await viteTransform(` ` , 'hello.server.vue') expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` " " `) }) it('expect slot fallback transform to match inline snapshot', async () => { const result = await viteTransform(` ` , 'hello.server.vue') expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` " " `) }) it('expect slot transform with fallback and no name to match inline snapshot #23209', async () => { const result = await viteTransform(` ` , 'hello.server.vue') expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` " " `) }) }) })