Add custom theming
This commit is contained in:
38
highlight_lexer_test.go
Normal file
38
highlight_lexer_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/alecthomas/chroma/v2/lexers"
|
||||
)
|
||||
|
||||
func TestLexerForPathUsesCompleteFilename(t *testing.T) {
|
||||
tests := []struct {
|
||||
path string
|
||||
want string
|
||||
}{
|
||||
{"Dockerfile", "Docker"},
|
||||
{"Makefile", "Makefile"},
|
||||
{"src/component.tsx", "TypeScript"},
|
||||
{"scripts/check.py", "Python"},
|
||||
{".github/workflows/test.yml", "YAML"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.path, func(t *testing.T) {
|
||||
got := lexerForPath(test.path)
|
||||
lexer := lexers.Get(got)
|
||||
if lexer == nil {
|
||||
t.Fatalf("lexerForPath(%q) = %q, which is not registered", test.path, got)
|
||||
}
|
||||
if lexer.Config().Name != test.want {
|
||||
t.Fatalf("lexerForPath(%q) selected %q, want %q", test.path, lexer.Config().Name, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLexerForUnknownPathAllowsContentAnalysis(t *testing.T) {
|
||||
if got := lexerForPath("LICENSE.unknown-extension"); got != "" {
|
||||
t.Fatalf("unknown path selected %q instead of allowing content analysis", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user