Download this file
| 1 | package chat |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/wire" |
| 8 | ) |
| 9 | |
| 10 | func TestCleanHeadline(t *testing.T) { |
| 11 | for in, want := range map[string]string{ |
| 12 | "Found it: hiding the navigation bar turned off swipe-back.": "Found it: hiding the navigation bar turned off swipe-back.", |
| 13 | " Approved.\nThe rest.": "Approved.", |
| 14 | "Fixed swipe-back. Couldn't test on iOS here.": "Fixed swipe-back. Couldn't test on iOS here.", |
| 15 | "Edited panes/swipe.go to go back.": "", |
| 16 | "The bug is in AccountNavigationHost.swift.": "", |
| 17 | "Look at `README.md` first.": "", |
| 18 | "Line host.go:15 returns false.": "", |
| 19 | "Released at 18:39, version 2.1 works.": "Released at 18:39, version 2.1 works.", |
| 20 | "": "", |
| 21 | } { |
| 22 | if got := cleanHeadline(in); got != want { |
| 23 | t.Errorf("cleanHeadline(%q) = %q, want %q", in, got, want) |
| 24 | } |
| 25 | } |
| 26 | long := cleanHeadline(strings.Repeat("swipe back works ", 20)) |
| 27 | if len(long) > wire.MaxHeadline+len("…") || !strings.HasSuffix(long, "…") || strings.Contains(long, " ") { |
| 28 | t.Fatalf("long headline %q (%d)", long, len(long)) |
| 29 | } |
| 30 | } |
| 31 | |