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 57dd9ab
Show file tree
Hide file tree
Showing 2 changed files with 37 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'));
});
36 changes: 36 additions & 0 deletions tests/specs/issues.ts
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);
}
});
});

0 comments on commit 57dd9ab

Please sign in to comment.