Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christianscott committed May 26, 2022
1 parent 07a8772 commit 8641356
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 0 deletions.
Empty file.
3 changes: 3 additions & 0 deletions __tests__/fixtures/tsconfigs/decls/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["./**/*.*"]
}
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions __tests__/fixtures/tsconfigs/extends/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../project/tsconfig.json",
"include": ["./**/*.*"]
}
Empty file.
3 changes: 3 additions & 0 deletions __tests__/fixtures/tsconfigs/glob/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["../decls/*.d.ts", "./**/*.*"]
}
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions __tests__/fixtures/tsconfigs/project/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["../decls/one.d.ts", "./**/*.*"]
}
29 changes: 29 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,33 @@ describe('dependencyTree', () => {
).rejects.toThrowErrorMatchingSnapshot();
});
});

describe('tsconfig', () => {
beforeEach(() => {
dependencyTree = new DependencyTree([fixture('tsconfigs')]);
});

it('adds files in `include` from nearest tsconfig.json', async () => {
expect.hasAssertions();
const result = await dependencyTree.gather();
const decl1 = fixture('tsconfigs', 'decls', 'one.d.ts');
const decl2 = fixture('tsconfigs', 'decls', 'two.d.ts');
expect(result).toStrictEqual({
missing: new Map(),
resolved: new Map([
[fixture('tsconfigs', 'project', 'project.ts'), new Set([decl1])],
[
fixture('tsconfigs', 'project', 'nested', 'nested.ts'),
new Set([decl1]),
],
[fixture('tsconfigs', 'glob', 'glob.ts'), new Set([decl1, decl2])],
// "includes" is overwritten in the child config
[fixture('tsconfigs', 'extends', 'extends.ts'), new Set([])],
// decls in the same dir that includes './**.*.*' depend on one another
[fixture('tsconfigs', 'decls', 'one.d.ts'), new Set([decl2])],
[fixture('tsconfigs', 'decls', 'two.d.ts'), new Set([decl1])],
]),
});
});
});
});

0 comments on commit 8641356

Please sign in to comment.