tweaks
This commit is contained in:
parent
1113988a10
commit
0001eb239c
|
|
@ -1,29 +0,0 @@
|
|||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { getRootClientInjectTarget, rootClientInjectTargetRelativePath } from '@/plugins/vite/inject-target'
|
||||
|
||||
const projectRoot = process.cwd()
|
||||
const rootLayoutFile = path.resolve(projectRoot, 'app/layout.tsx')
|
||||
const rootClientInjectTarget = getRootClientInjectTarget(projectRoot)
|
||||
|
||||
describe('vite dev inject target', () => {
|
||||
describe('target module', () => {
|
||||
it('should point to an existing root-mounted client component', () => {
|
||||
expect(rootClientInjectTarget).toBe(path.resolve(projectRoot, rootClientInjectTargetRelativePath))
|
||||
expect(fs.existsSync(rootClientInjectTarget)).toBe(true)
|
||||
|
||||
const targetCode = fs.readFileSync(rootClientInjectTarget, 'utf-8')
|
||||
|
||||
expect(targetCode).toMatch(/^'use client'/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('root layout wiring', () => {
|
||||
it('should import and render the inject target from the root layout', () => {
|
||||
const layoutCode = fs.readFileSync(rootLayoutFile, 'utf-8')
|
||||
|
||||
expect(layoutCode).toContain('import RoutePrefixHandle from \'./routePrefixHandle\'')
|
||||
expect(layoutCode).toContain('<RoutePrefixHandle />')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'node:path'
|
||||
|
||||
export const rootClientInjectTargetRelativePath = 'app/routePrefixHandle.tsx'
|
||||
export const rootClientInjectTargetRelativePath = 'instrumentation-client.ts'
|
||||
|
||||
export const getRootClientInjectTarget = (projectRoot: string): string => {
|
||||
return path.resolve(projectRoot, rootClientInjectTargetRelativePath)
|
||||
|
|
|
|||
Loading…
Reference in New Issue