(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestApplyThemePrecedence(t *testing.T) { |
| 41 | // Not parallel: mutates the process-global applied theme via ApplyTheme. |
| 42 | // Isolate config/data dirs so a developer's real user config (which may |
| 43 | // pin a theme) cannot influence the precedence assertions. |
| 44 | dir := t.TempDir() |
| 45 | paths.SetConfigDir(dir) |
| 46 | paths.SetDataDir(dir) |
| 47 | t.Cleanup(func() { |
| 48 | paths.SetConfigDir("") |
| 49 | paths.SetDataDir("") |
| 50 | }) |
| 51 | |
| 52 | t.Run("override takes precedence and is applied", func(t *testing.T) { |
| 53 | applyTheme("nord") |
| 54 | assert.Equal(t, "nord", styles.CurrentTheme().Ref) |
| 55 | }) |
| 56 | |
| 57 | t.Run("invalid override falls back to default theme", func(t *testing.T) { |
| 58 | // applyTheme tolerates an invalid ref (validateTheme guards the CLI |
| 59 | // entry point); it must never panic and should apply the default. |
| 60 | applyTheme("does-not-exist") |
| 61 | assert.Equal(t, styles.DefaultThemeRef, styles.CurrentTheme().Ref) |
| 62 | }) |
| 63 | |
| 64 | t.Run("empty override applies default when no user config theme", func(t *testing.T) { |
| 65 | applyTheme("") |
| 66 | assert.Equal(t, styles.DefaultThemeRef, styles.CurrentTheme().Ref) |
| 67 | }) |
| 68 | } |
nothing calls this directly
no test coverage detected