Skip to content

Commit

Permalink
Extend the test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabotechs committed Jun 30, 2024
1 parent c74c613 commit 9cc4e28
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions internal/js/tsconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,40 @@ import (
func TestTsConfig_ResolveFromPaths(t *testing.T) {
tests := []struct {
Name string
basePath string
Paths map[string][]string
TsConfig TsConfig
Import string
Result []string
}{
{
Name: "without globstar",
basePath: "/foo/bar",
Paths: map[string][]string{"@/": {"./src/"}},
Import: "@/a/b/c",
Result: []string{"/foo/bar/src/a/b/c"},
Name: "without globstar",
TsConfig: TsConfig{
path: "/foo",
CompilerOptions: CompilerOptions{
BaseUrl: "./bar/baz",
Paths: map[string][]string{"@/": {"./src/"}},
},
},
Import: "@/a/b/c",
Result: []string{"/foo/bar/baz/src/a/b/c"},
},
{
Name: "without globstar (2)",
basePath: "/foo/bar",
Paths: map[string][]string{"@Environment": {"./src/environments/environments.ts"}},
Import: "@Environment",
Result: []string{"/foo/bar/src/environments/environments.ts"},
Name: "without globstar (2)",
TsConfig: TsConfig{
path: "/foo",
CompilerOptions: CompilerOptions{
BaseUrl: "./bar/baz",
Paths: map[string][]string{"@Environment": {"./src/environments/environments.ts"}},
},
},
Import: "@Environment",
Result: []string{"/foo/bar/baz/src/environments/environments.ts"},
},
}

for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
a := require.New(t)
tsConfig := TsConfig{
path: tt.basePath,
CompilerOptions: CompilerOptions{
Paths: tt.Paths,
},
}
result := tsConfig.ResolveFromPaths(tt.Import)
result := tt.TsConfig.ResolveFromPaths(tt.Import)
a.Equal(tt.Result, result)
})
}
Expand Down

0 comments on commit 9cc4e28

Please sign in to comment.