2024-04-19 09:43:28 +00:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { resolve } from 'pathe'
|
|
|
|
import { loadNuxt } from './loader/nuxt'
|
|
|
|
import { findPath, resolvePath } from './resolve'
|
|
|
|
import { defineNuxtModule } from './module/define'
|
|
|
|
import { addTemplate } from './template'
|
|
|
|
|
|
|
|
const nuxt = await loadNuxt({
|
|
|
|
overrides: {
|
|
|
|
modules: [
|
|
|
|
defineNuxtModule(() => {
|
|
|
|
addTemplate({
|
|
|
|
filename: 'my-template.mjs',
|
|
|
|
getContents: () => 'export const myUtil = () => \'hello\'',
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('resolvePath', () => {
|
|
|
|
it('should resolve paths correctly', async () => {
|
2025-02-10 13:29:48 +00:00
|
|
|
expect(await resolvePath('.nuxt/app.config')).toBe(resolve('.nuxt/app.config.mjs'))
|
2024-04-19 09:43:28 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('findPath', () => {
|
|
|
|
it('should find paths correctly', async () => {
|
|
|
|
expect(await findPath(resolve(nuxt.options.buildDir, 'my-template'), { virtual: true })).toBe(resolve(nuxt.options.buildDir, 'my-template.mjs'))
|
|
|
|
})
|
|
|
|
})
|