You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
2.1 KiB

  1. package main
  2. import (
  3. "testing"
  4. "github.com/zorchenhimer/MovieNight/common"
  5. )
  6. func TestClient_addSpoilerTag(t *testing.T) {
  7. data := [][]string{
  8. {"||||", spoilerStart + spoilerEnd},
  9. {"|||||", spoilerStart + spoilerEnd + "|"},
  10. {"||||||", spoilerStart + spoilerEnd + "||"},
  11. {"|||||||", spoilerStart + spoilerEnd + "|||"},
  12. {"||||||||", spoilerStart + spoilerEnd + spoilerStart + spoilerEnd},
  13. {"||test||", spoilerStart + "test" + spoilerEnd},
  14. {"|| ||", spoilerStart + " " + spoilerEnd},
  15. {"|s|||", "|s|||"},
  16. }
  17. for i := range data {
  18. s := addSpoilerTags(data[i][0])
  19. if s != data[i][1] {
  20. t.Errorf("expected %#v, got %#v with %#v", data[i][1], s, data[i][0])
  21. }
  22. }
  23. }
  24. // Name highlighting should not interfere with emotes
  25. func TestClient_emoteHighlight(t *testing.T) {
  26. data := [][]string{
  27. {"zorchenhimer", `<span class="mention">zorchenhimer</span>`},
  28. {"@zorchenhimer", `<span class="mention">@zorchenhimer</span>`},
  29. {"Zorchenhimer", `<span class="mention">Zorchenhimer</span>`},
  30. {"@Zorchenhimer", `<span class="mention">@Zorchenhimer</span>`},
  31. {"hello zorchenhimer", `hello <span class="mention">zorchenhimer</span>`},
  32. {"hello zorchenhimer ass", `hello <span class="mention">zorchenhimer</span> ass`},
  33. {`<img src="/emotes/twitch/zorchenhimer/zorcheWhat.png" height="28px" title="zorcheWhat">`, `<img src="/emotes/twitch/zorchenhimer/zorcheWhat.png" height="28px" title="zorcheWhat">`},
  34. {`zorchenhimer <img src="/emotes/twitch/zorchenhimer/zorcheWhat.png" height="28px" title="zorcheWhat">`, `<span class="mention">zorchenhimer</span> <img src="/emotes/twitch/zorchenhimer/zorcheWhat.png" height="28px" title="zorcheWhat">`},
  35. }
  36. client, err := NewClient(nil, nil, "Zorchenhimer", "#9547ff")
  37. if err != nil {
  38. t.Errorf("Client init error: %v", err)
  39. }
  40. for _, d := range data {
  41. chatData := client.replaceColorizedName(common.NewChatMessage(client.name, client.color, d[0], common.CmdlUser, common.MsgChat))
  42. if chatData.Data.(common.DataMessage).Message != d[1] {
  43. t.Errorf("\nExpected:\n\t%s\nReceived\n\t%s", d[1], chatData.Data.(common.DataMessage).Message)
  44. } else {
  45. t.Logf("Passed %s", d[0])
  46. }
  47. }
  48. }