Skip to content

Commit

Permalink
test: add failing test for qmhc#330
Browse files Browse the repository at this point in the history
  • Loading branch information
lachieh committed Oct 8, 2024
1 parent 1232266 commit a984e86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 9 additions & 1 deletion tests/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ describe('transform tests', () => {
{ find: /^@\/(.+)/, replacement: resolve(__dirname, '../$1') },
{ find: /^@components\/(.+)/, replacement: resolve(__dirname, '../src/components/$1') },
{ find: /^~\//, replacement: resolve(__dirname, '../src/') },
{ find: '$src', replacement: resolve(__dirname, '../src') }
{ find: '$src', replacement: resolve(__dirname, '../src') },
{ find: /^(.+)$/, replacement: resolve(__dirname, '../src/$1') }
]
const filePath = resolve(__dirname, '../src/index.ts')

Expand Down Expand Up @@ -121,6 +122,13 @@ describe('transform tests', () => {
content: 'import("@/components/test").Test;',
output: "import('../components/test').Test;"
},
{
// https://github.com/qmhc/vite-plugin-dts/issues/330
description: 'dynamic import with inside subfolder with wildcard alias at root level',
filePath: './src/components/Sample/index.ts',
content: 'import {Sample} from "./test";',
output: "import {Sample} from './test';"
},
{
description: 'import inside folder with named alias at subfolder',
content: 'import type { TestBase } from "@/components/test";',
Expand Down
7 changes: 2 additions & 5 deletions tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,8 @@ describe('utils tests', () => {
})

it('test: getTsLibFolder', () => {
const root = normalizePath(resolve(__dirname, '..'))
const entryRoot = resolve(root, 'src')

expect(getTsLibFolder({ root, entryRoot })).toMatch(/node_modules\/typescript$/)
expect(getTsLibFolder()).toMatch(/node_modules\/typescript$/)

expect(existsSync(getTsLibFolder({ root, entryRoot }) || '')).toBe(true)
expect(existsSync(getTsLibFolder() || '')).toBe(true)
})
})

0 comments on commit a984e86

Please sign in to comment.