diff --git a/src/converter/convertFile.test.ts b/src/converter/convertFile.test.ts index 4f41842..9bdc6af 100644 --- a/src/converter/convertFile.test.ts +++ b/src/converter/convertFile.test.ts @@ -2,15 +2,20 @@ import path from 'node:path'; import {ProjectUtil} from '../util/ProjectUtil.js'; import {convertFile} from './convertFile.js'; -describe('convertFile', () => { +describe.only('convertFile', () => { const fixtures = path.join(process.cwd(), 'src', 'test', 'fixtures'); it('fixes imports from index files', async () => { const projectDir = path.join(fixtures, 'index-import'); const projectConfig = path.join(projectDir, 'tsconfig.json'); - const snapshot = path.join(projectDir, 'main.snap.ts'); + const snapshot = path.join(projectDir, 'src', 'main.snap.ts'); const project = ProjectUtil.getProject(projectConfig); - const modifiedFile = convertFile(project, project.getSourceFile('main.ts')!, true); + + const sourceFile = project.getSourceFile('main.ts')!; + const modifiedFile = convertFile(project, sourceFile, true); + await expect(modifiedFile.getText()).toMatchFileSnapshot(snapshot); }); + + it.todo('fixes imports when tsconfig has an "include" property'); }); diff --git a/src/test/fixtures/index-import/main.snap.ts b/src/test/fixtures/index-import/main.snap.ts index 3d996f8..8e7693e 100644 --- a/src/test/fixtures/index-import/main.snap.ts +++ b/src/test/fixtures/index-import/main.snap.ts @@ -1,3 +1,3 @@ -import {MY_CONSTANT} from './src/index.js'; +import {MY_CONSTANT} from './src/index'; console.log(MY_CONSTANT); diff --git a/src/test/fixtures/index-import/main.ts b/src/test/fixtures/index-import/main.ts deleted file mode 100644 index 3d996f8..0000000 --- a/src/test/fixtures/index-import/main.ts +++ /dev/null @@ -1,3 +0,0 @@ -import {MY_CONSTANT} from './src/index.js'; - -console.log(MY_CONSTANT); diff --git a/src/test/fixtures/index-import/src/index.ts b/src/test/fixtures/index-import/src/lib/index.ts similarity index 100% rename from src/test/fixtures/index-import/src/index.ts rename to src/test/fixtures/index-import/src/lib/index.ts diff --git a/src/test/fixtures/index-import/src/main.snap.ts b/src/test/fixtures/index-import/src/main.snap.ts new file mode 100644 index 0000000..2063309 --- /dev/null +++ b/src/test/fixtures/index-import/src/main.snap.ts @@ -0,0 +1,3 @@ +import {MY_CONSTANT} from './lib/index.js'; + +console.log(MY_CONSTANT); diff --git a/src/test/fixtures/index-import/src/main.ts b/src/test/fixtures/index-import/src/main.ts new file mode 100644 index 0000000..5f07966 --- /dev/null +++ b/src/test/fixtures/index-import/src/main.ts @@ -0,0 +1,4 @@ +// @ts-ignore +import {MY_CONSTANT} from './lib'; + +console.log(MY_CONSTANT); diff --git a/src/test/fixtures/tsconfig-include/consumer.snap.ts b/src/test/fixtures/tsconfig-include/consumer.snap.ts index 731e023..426f3cb 100644 --- a/src/test/fixtures/tsconfig-include/consumer.snap.ts +++ b/src/test/fixtures/tsconfig-include/consumer.snap.ts @@ -1,3 +1,3 @@ -import {MY_CONSTANT} from './src/producer'; +import {MY_CONSTANT} from './lib/producer.js'; console.log(MY_CONSTANT); diff --git a/src/test/fixtures/tsconfig-include/consumer.ts b/src/test/fixtures/tsconfig-include/consumer.ts deleted file mode 100644 index 731e023..0000000 --- a/src/test/fixtures/tsconfig-include/consumer.ts +++ /dev/null @@ -1,3 +0,0 @@ -import {MY_CONSTANT} from './src/producer'; - -console.log(MY_CONSTANT); diff --git a/src/test/fixtures/tsconfig-include/src/consumer.snap.ts b/src/test/fixtures/tsconfig-include/src/consumer.snap.ts new file mode 100644 index 0000000..426f3cb --- /dev/null +++ b/src/test/fixtures/tsconfig-include/src/consumer.snap.ts @@ -0,0 +1,3 @@ +import {MY_CONSTANT} from './lib/producer.js'; + +console.log(MY_CONSTANT); diff --git a/src/test/fixtures/tsconfig-include/src/consumer.ts b/src/test/fixtures/tsconfig-include/src/consumer.ts new file mode 100644 index 0000000..a59eaec --- /dev/null +++ b/src/test/fixtures/tsconfig-include/src/consumer.ts @@ -0,0 +1,4 @@ +// @ts-ignore +import {MY_CONSTANT} from './lib/producer'; + +console.log(MY_CONSTANT); diff --git a/src/test/fixtures/tsconfig-include/src/producer.ts b/src/test/fixtures/tsconfig-include/src/lib/producer.ts similarity index 100% rename from src/test/fixtures/tsconfig-include/src/producer.ts rename to src/test/fixtures/tsconfig-include/src/lib/producer.ts