summaryrefslogtreecommitdiffstats
path: root/model/preference_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-07-14 10:08:36 -0400
committerChristopher Speller <crspeller@gmail.com>2016-07-14 10:08:36 -0400
commitcaabfbcdd56bdced7c5c1d38e00f488adffe7c60 (patch)
tree4d52326767246f331da352f0427e34bf714e3130 /model/preference_test.go
parent8e810bc2ebb743717b5b0fc4541fcd3b2565966c (diff)
downloadchat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.tar.gz
chat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.tar.bz2
chat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.zip
PLT-2992 Added the ability to use different themes for each team (#3411)
* Cleaned up user_settings_theme.jsx and import_theme_modal.jsx * Made ImportThemeModal use a callback to return the theme to the user settings modal instead of saving it directly * Moved user theme from model to preferences * Added serverside API to delete preferences TODO update package with client stuff * Changed constants.jsx so that Preferences and ActionTypes can be imported on their own * Updated ThemeProps migration code to properly rename solarized code themes * Fixed warnings thrown by AppDispatcher * Added clientside UI to support team-specific themes * Removed debugging code from test * Fixed setting a user's theme when they haven't set their theme before
Diffstat (limited to 'model/preference_test.go')
-rw-r--r--model/preference_test.go39
1 files changed, 36 insertions, 3 deletions
diff --git a/model/preference_test.go b/model/preference_test.go
index e29250bba..df7fe612d 100644
--- a/model/preference_test.go
+++ b/model/preference_test.go
@@ -4,6 +4,7 @@
package model
import (
+ "encoding/json"
"strings"
"testing"
)
@@ -31,7 +32,7 @@ func TestPreferenceIsValid(t *testing.T) {
preference.Category = PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW
if err := preference.IsValid(); err != nil {
- t.Fatal()
+ t.Fatal(err)
}
preference.Name = strings.Repeat("01234567890", 20)
@@ -41,16 +42,48 @@ func TestPreferenceIsValid(t *testing.T) {
preference.Name = NewId()
if err := preference.IsValid(); err != nil {
- t.Fatal()
+ t.Fatal(err)
}
- preference.Value = strings.Repeat("01234567890", 20)
+ preference.Value = strings.Repeat("01234567890", 201)
if err := preference.IsValid(); err == nil {
t.Fatal()
}
preference.Value = "1234garbage"
if err := preference.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+
+ preference.Category = PREFERENCE_CATEGORY_THEME
+ if err := preference.IsValid(); err == nil {
t.Fatal()
}
+
+ preference.Value = `{"color": "#ff0000", "color2": "#faf"}`
+ if err := preference.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestPreferencePreUpdate(t *testing.T) {
+ preference := Preference{
+ Category: PREFERENCE_CATEGORY_THEME,
+ Value: `{"color": "#ff0000", "color2": "#faf", "codeTheme": "github", "invalid": "invalid"}`,
+ }
+
+ preference.PreUpdate()
+
+ var props map[string]string
+ if err := json.NewDecoder(strings.NewReader(preference.Value)).Decode(&props); err != nil {
+ t.Fatal(err)
+ }
+
+ if props["color"] != "#ff0000" || props["color2"] != "#faf" || props["codeTheme"] != "github" {
+ t.Fatal("shouldn't have changed valid props")
+ }
+
+ if props["invalid"] == "invalid" {
+ t.Fatal("should have changed invalid prop")
+ }
}