feat(theming): integrate NvChad chadrc rewrite into Apply
This commit is contained in:
@@ -117,3 +117,34 @@ func TestApplyPreservesOtherOverlayKeys(t *testing.T) {
|
||||
t.Fatalf("active theme missing after preserve: %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyRewritesChadrcIfPresent(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
nvimCfg := filepath.Join(home, ".config", "nvim", "lua")
|
||||
if err := os.MkdirAll(nvimCfg, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(nvimCfg, "chadrc.lua"),
|
||||
[]byte(`M.base46 = { theme = "onedark" }`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Apply(config.Config{}, "gruvbox"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
data, _ := os.ReadFile(filepath.Join(nvimCfg, "chadrc.lua"))
|
||||
if !strings.Contains(string(data), `theme = "gruvbox"`) {
|
||||
t.Fatalf("chadrc not rewritten: %s", data)
|
||||
}
|
||||
if strings.Contains(string(data), `theme = "onedark"`) {
|
||||
t.Fatalf("old theme still present: %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyNoChadrcIsFine(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
if err := Apply(config.Config{}, "gruvbox"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user