-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebc0f73
commit 57dd9ab
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import path from 'path'; | ||
import { createFixture } from 'fs-fixture'; | ||
import { expect, testSuite } from 'manten'; | ||
import { createTsconfigJson } from '../utils.js'; | ||
import { createPathsMatcher, getTsconfig } from '#get-tsconfig'; | ||
|
||
export default testSuite(({ test }) => { | ||
test('#79 implicit relative base url', async () => { | ||
await using fixture = await createFixture({ | ||
'some-dir/src/file.ts': '', | ||
'some-dir/tsconfig.json': createTsconfigJson({ | ||
compilerOptions: { | ||
paths: { | ||
'@/*': ['./src/*'], | ||
}, | ||
}, | ||
}), | ||
}); | ||
|
||
const originalCwd = process.cwd(); | ||
|
||
try { | ||
process.chdir(fixture.path); | ||
|
||
const tsconfig = getTsconfig('./some-dir'); | ||
expect(tsconfig).not.toBeNull(); | ||
|
||
const matcher = createPathsMatcher(tsconfig!)!; | ||
expect(matcher).not.toBeNull(); | ||
|
||
expect(matcher('@/file.ts').at(0)).toBe(path.join(fixture.path, 'some-dir/src/file.ts')); | ||
} finally { | ||
process.chdir(originalCwd); | ||
} | ||
}); | ||
}); |