shadcn-vue/packages/cli/test/utils/updaters/update-files.test.ts
2024-11-27 11:28:21 +08:00

67 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { resolveTargetDir } from '../../../src/utils/updaters/update-files'
// TODO: `isSrcDir` is not being use yet
describe('resolveTargetDir', () => {
it('should handle a home target without a src directory', () => {
const targetDir = resolveTargetDir(
{
isSrcDir: false,
},
{
resolvedPaths: {
cwd: '/foo/bar',
},
},
'~/.env',
)
expect(targetDir).toBe('/foo/bar/.env')
})
it('should handle a home target even with a src directory', () => {
const targetDir = resolveTargetDir(
{
isSrcDir: true,
},
{
resolvedPaths: {
cwd: '/foo/bar',
},
},
'~/.env',
)
expect(targetDir).toBe('/foo/bar/.env')
})
it('should handle a simple target', () => {
const targetDir = resolveTargetDir(
{
isSrcDir: false,
},
{
resolvedPaths: {
cwd: '/foo/bar',
},
},
'./components/ui/button.ts',
)
expect(targetDir).toBe('/foo/bar/components/ui/button.ts')
})
it('should handle a simple target with src directory', () => {
const targetDir = resolveTargetDir(
{
isSrcDir: true,
},
{
resolvedPaths: {
cwd: '/foo/bar',
},
},
'./components/ui/button.ts',
)
expect(targetDir).toBe('/foo/bar/components/ui/button.ts')
})
})