35 lines
864 B
Go
35 lines
864 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestApplyThemeChangesAllRenderingThemes(t *testing.T) {
|
|
defer func() {
|
|
if err := applyTheme("dark"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}()
|
|
if err := applyTheme("light"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if markdownStyleName != "light" || codeHighlightTheme != "github" {
|
|
t.Fatalf("light theme did not propagate: markdown=%q code=%q", markdownStyleName, codeHighlightTheme)
|
|
}
|
|
if err := applyTheme("unknown"); err == nil {
|
|
t.Fatal("unknown theme was accepted")
|
|
}
|
|
}
|
|
|
|
func TestNoColorThemeDisablesSyntaxColors(t *testing.T) {
|
|
defer applyTheme("dark")
|
|
if err := applyTheme("no-color"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
rendered := highlightedSource("go", "func main() {}")
|
|
if strings.Contains(rendered, "\x1b[") || colorEnabled {
|
|
t.Fatalf("no-color source contains terminal colors: %q", rendered)
|
|
}
|
|
}
|