Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrestone committed May 6, 2022
1 parent e31a5d6 commit a7e2bdf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/jsii/lib/project-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TSCompilerOptions {
readonly outDir?: string;
readonly rootDir?: string;
readonly forceConsistentCasingInFileNames?: boolean;
readonly declarationMap?: boolean;
}

export interface ProjectInfo {
Expand Down
42 changes: 42 additions & 0 deletions packages/jsii/test/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ describe(Compiler, () => {
});
});

test('declaration map option can be set', () => {
const sourceDir = mkdtempSync(join(tmpdir(), 'jsii-compiler-watch-mode-'));

const compiler = new Compiler({
projectInfo: {
..._makeProjectInfo(sourceDir, 'index.d.ts'),
tsc: { declarationMap: true },
},
generateTypeScriptConfig: 'tsconfig.jsii.json',
});

compiler.emit();

expect(
readJsonSync(join(sourceDir, 'tsconfig.jsii.json'), 'utf-8'),
).toHaveProperty('compilerOptions.declarationMap', true);
});

test('emits declaration map', () => {
const sourceDir = mkdtempSync(join(tmpdir(), 'jsii-tmpdir'));

try {
writeFileSync(join(sourceDir, 'index.ts'), 'export class MarkerA {}');

const compiler = new Compiler({
projectInfo: {
..._makeProjectInfo(sourceDir, 'index.d.ts'),
tsc: { declarationMap: true },
},
generateTypeScriptConfig: 'tsconfig.jsii.json',
});

compiler.emit();

expect(() => {
readFileSync(join(sourceDir, 'index.d.ts.map'), 'utf-8');
}).not.toThrow();
} finally {
removeSync(sourceDir);
}
});

test('"watch" mode', async () => {
// This can be a little slow, allowing 15 seconds maximum here (default is 5 seconds)
jest.setTimeout(15_000);
Expand Down

0 comments on commit a7e2bdf

Please sign in to comment.