file_system_preference_test.go 1.0 KB

123456789101112131415161718192021222324252627282930
  1. package main
  2. import "testing"
  3. /*
  4. A user who never picked a theme must get the backend's default. Pages read
  5. the preference as "dark unless whiteTheme", so an empty reply turns them dark
  6. while the desktop itself stays light.
  7. */
  8. func TestUserPreferenceOrDefault(t *testing.T) {
  9. tests := []struct {
  10. name string
  11. key string
  12. stored string
  13. want string
  14. }{
  15. {"unset theme gets the light default", "file_explorer/theme", "", "whiteTheme"},
  16. {"stored dark theme is kept", "file_explorer/theme", "darkTheme", "darkTheme"},
  17. {"stored white theme is kept", "file_explorer/theme", "whiteTheme", "whiteTheme"},
  18. {"unset key without a default stays empty", "file_explorer/oprbar", "", ""},
  19. {"stored key without a default is kept", "file_explorer/oprbar", "false", "false"},
  20. }
  21. for _, tt := range tests {
  22. t.Run(tt.name, func(t *testing.T) {
  23. if got := system_fs_userPreferenceOrDefault(tt.key, tt.stored); got != tt.want {
  24. t.Errorf("system_fs_userPreferenceOrDefault(%q, %q) = %q, want %q", tt.key, tt.stored, got, tt.want)
  25. }
  26. })
  27. }
  28. }