package routes

import (
	"strings"
	"testing"
)

func TestWithContactPhone(t *testing.T) {
	cases := []struct{ message, phone, want string }{
		{"Hello", "", "Hello"},
		{"Hello", "  ", "Hello"},
		{"Hello", "(800) 345-1442", "Hello\n\nPhone: (800) 345-1442"},
		{"", "555", "Phone: 555"},
		{"Hi", "1234567890123456789012345678901234567890XYZ", "Hi\n\nPhone: 1234567890123456789012345678901234567890"},
		// 20 three-byte characters: the cut lands on the 13th's last byte, so 13 are kept whole.
		{"Hi", strings.Repeat("€", 20), "Hi\n\nPhone: " + strings.Repeat("€", 13)},
	}
	for _, c := range cases {
		if got := withContactPhone(c.message, c.phone); got != c.want {
			t.Errorf("withContactPhone(%q, %q) = %q, want %q", c.message, c.phone, got, c.want)
		}
	}
}
