package main import ( "testing" "github.com/zorchenhimer/MovieNight/common" ) func TestClient_addSpoilerTag(t *testing.T) { data := [][]string{ {"||||", spoilerStart + spoilerEnd}, {"|||||", spoilerStart + spoilerEnd + "|"}, {"||||||", spoilerStart + spoilerEnd + "||"}, {"|||||||", spoilerStart + spoilerEnd + "|||"}, {"||||||||", spoilerStart + spoilerEnd + spoilerStart + spoilerEnd}, {"||test||", spoilerStart + "test" + spoilerEnd}, {"|| ||", spoilerStart + " " + spoilerEnd}, {"|s|||", "|s|||"}, } for i := range data { s := addSpoilerTags(data[i][0]) if s != data[i][1] { t.Errorf("expected %#v, got %#v with %#v", data[i][1], s, data[i][0]) } } } // Name highlighting should not interfere with emotes func TestClient_emoteHighlight(t *testing.T) { data := [][]string{ {"zorchenhimer", `zorchenhimer`}, {"@zorchenhimer", `@zorchenhimer`}, {"Zorchenhimer", `Zorchenhimer`}, {"@Zorchenhimer", `@Zorchenhimer`}, {"hello zorchenhimer", `hello zorchenhimer`}, {"hello zorchenhimer ass", `hello zorchenhimer ass`}, {``, ``}, {`zorchenhimer `, `zorchenhimer `}, } client, err := NewClient(nil, nil, "Zorchenhimer", "#9547ff") if err != nil { t.Errorf("Client init error: %v", err) } for _, d := range data { chatData := client.replaceColorizedName(common.NewChatMessage(client.name, client.color, d[0], common.CmdlUser, common.MsgChat)) if chatData.Data.(common.DataMessage).Message != d[1] { t.Errorf("\nExpected:\n\t%s\nReceived\n\t%s", d[1], chatData.Data.(common.DataMessage).Message) } else { t.Logf("Passed %s", d[0]) } } }