|
| 1 | +package tsoptions |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/microsoft/typescript-go/internal/tspath" |
| 7 | +) |
| 8 | + |
| 9 | +func TestGetWildcardDirectories_NonASCIICharacters(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + |
| 12 | + tests := []struct { |
| 13 | + name string |
| 14 | + include []string |
| 15 | + exclude []string |
| 16 | + currentDirectory string |
| 17 | + useCaseSensitiveFileNames bool |
| 18 | + }{ |
| 19 | + { |
| 20 | + name: "Norwegian character æ in path", |
| 21 | + include: []string{"src/**/*.test.ts", "src/**/*.stories.ts", "src/**/*.mdx"}, |
| 22 | + exclude: []string{"node_modules"}, |
| 23 | + currentDirectory: "C:/Users/TobiasLægreid/dev/app/frontend/packages/react", |
| 24 | + useCaseSensitiveFileNames: false, |
| 25 | + }, |
| 26 | + { |
| 27 | + name: "Japanese characters in path", |
| 28 | + include: []string{"src/**/*.ts"}, |
| 29 | + exclude: []string{"テスト"}, |
| 30 | + currentDirectory: "/Users/ユーザー/プロジェクト", |
| 31 | + useCaseSensitiveFileNames: true, |
| 32 | + }, |
| 33 | + { |
| 34 | + name: "Chinese characters in path", |
| 35 | + include: []string{"源代码/**/*.js"}, |
| 36 | + exclude: []string{"节点模块"}, |
| 37 | + currentDirectory: "/home/用户/项目", |
| 38 | + useCaseSensitiveFileNames: true, |
| 39 | + }, |
| 40 | + { |
| 41 | + name: "Various Unicode characters", |
| 42 | + include: []string{"src/**/*.ts"}, |
| 43 | + exclude: []string{"node_modules"}, |
| 44 | + currentDirectory: "/Users/Müller/café/naïve/résumé", |
| 45 | + useCaseSensitiveFileNames: false, |
| 46 | + }, |
| 47 | + } |
| 48 | + |
| 49 | + for _, tt := range tests { |
| 50 | + t.Run(tt.name, func(t *testing.T) { |
| 51 | + t.Parallel() |
| 52 | + |
| 53 | + comparePathsOptions := tspath.ComparePathsOptions{ |
| 54 | + CurrentDirectory: tt.currentDirectory, |
| 55 | + UseCaseSensitiveFileNames: tt.useCaseSensitiveFileNames, |
| 56 | + } |
| 57 | + |
| 58 | + result := getWildcardDirectories(tt.include, tt.exclude, comparePathsOptions) |
| 59 | + |
| 60 | + if result == nil { |
| 61 | + t.Fatalf("expected non-nil result") |
| 62 | + } |
| 63 | + }) |
| 64 | + } |
| 65 | +} |
0 commit comments