1package lsp
 2
 3import (
 4	"testing"
 5
 6	"github.com/stretchr/testify/require"
 7)
 8
 9func TestHandlesFile(t *testing.T) {
10	tests := []struct {
11		name      string
12		fileTypes []string
13		filepath  string
14		expected  bool
15	}{
16		{
17			name:      "no file types specified - handles all files",
18			fileTypes: nil,
19			filepath:  "test.go",
20			expected:  true,
21		},
22		{
23			name:      "empty file types - handles all files",
24			fileTypes: []string{},
25			filepath:  "test.go",
26			expected:  true,
27		},
28		{
29			name:      "matches .go extension",
30			fileTypes: []string{".go"},
31			filepath:  "main.go",
32			expected:  true,
33		},
34		{
35			name:      "matches go extension without dot",
36			fileTypes: []string{"go"},
37			filepath:  "main.go",
38			expected:  true,
39		},
40		{
41			name:      "matches one of multiple extensions",
42			fileTypes: []string{".js", ".ts", ".tsx"},
43			filepath:  "component.tsx",
44			expected:  true,
45		},
46		{
47			name:      "does not match extension",
48			fileTypes: []string{".go", ".rs"},
49			filepath:  "script.sh",
50			expected:  false,
51		},
52		{
53			name:      "matches with full path",
54			fileTypes: []string{".sh"},
55			filepath:  "/usr/local/bin/script.sh",
56			expected:  true,
57		},
58		{
59			name:      "case insensitive matching",
60			fileTypes: []string{".GO"},
61			filepath:  "main.go",
62			expected:  true,
63		},
64		{
65			name:      "bash file types",
66			fileTypes: []string{".sh", ".bash", ".zsh", ".ksh"},
67			filepath:  "script.sh",
68			expected:  true,
69		},
70		{
71			name:      "bash should not handle go files",
72			fileTypes: []string{".sh", ".bash", ".zsh", ".ksh"},
73			filepath:  "main.go",
74			expected:  false,
75		},
76		{
77			name:      "bash should not handle json files",
78			fileTypes: []string{".sh", ".bash", ".zsh", ".ksh"},
79			filepath:  "config.json",
80			expected:  false,
81		},
82	}
83
84	for _, tt := range tests {
85		t.Run(tt.name, func(t *testing.T) {
86			client := &Client{
87				fileTypes: tt.fileTypes,
88			}
89			result := client.HandlesFile(tt.filepath)
90			require.Equal(t, tt.expected, result)
91		})
92	}
93}