Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
effervescentia committed Mar 29, 2023
1 parent b935fe4 commit 9a46e67
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
7 changes: 7 additions & 0 deletions example/inherited/tsconfig.base.json
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@": []
}
}
}
3 changes: 3 additions & 0 deletions example/inherited/tsconfig.json
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.preset.json"
}
3 changes: 3 additions & 0 deletions example/inherited/tsconfig.preset.json
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.base.json"
}
18 changes: 17 additions & 1 deletion src/__tests__/tsconfig-loader.test.ts
Expand Up @@ -3,7 +3,7 @@ import {
tsConfigLoader,
walkForTsConfig,
} from "../tsconfig-loader";
import { join } from "path";
import { join, resolve } from "path";

describe("tsconfig-loader", () => {
it("should find tsconfig in cwd", () => {
Expand Down Expand Up @@ -166,3 +166,19 @@ describe("walkForTsConfig", () => {
expect(res).toBeUndefined();
});
});

describe("loadSyncDefault", () => {
it("should result multiple levels of tsconfig extension", () => {
const cwd = resolve(__dirname, "../../example/inherited");
const result = tsConfigLoader({
cwd,
getEnv: (_: string) => undefined,
});

expect(result).toEqual({
baseUrl: undefined,
paths: { "@": [] },
tsConfigPath: resolve(cwd, "tsconfig.json"),
});
});
});
2 changes: 1 addition & 1 deletion src/tsconfig-loader.ts
Expand Up @@ -32,7 +32,7 @@ export function tsConfigLoader({
return loadResult;
}

function loadSyncDefault(
export function loadSyncDefault(
cwd: string,
filename?: string,
baseUrl?: string
Expand Down

0 comments on commit 9a46e67

Please sign in to comment.