Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Jul 18, 2024
1 parent ebc0f73 commit 8e972d2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ describe('get-tsconfig', ({ runTestSuite }) => {
runTestSuite(import('./specs/parse-tsconfig/index.js'));
runTestSuite(import('./specs/create-paths-matcher.js'));
runTestSuite(import('./specs/create-files-matcher.js'));
runTestSuite(import('./specs/issues.js'));
});
38 changes: 38 additions & 0 deletions tests/specs/issues.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// tests/specs/issues.ts

import { createPathsMatcher, getTsconfig } from '#get-tsconfig';
import { createFixture } from 'fs-fixture';
import { expect, testSuite } from 'manten';
import { join } from 'path';
import { createTsconfigJson } from '../utils.js';

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(join(fixture.path, "some-dir/src/file.ts"));
} finally {
process.chdir(originalCwd);
}
})
})

0 comments on commit 8e972d2

Please sign in to comment.