package outreach

import "testing"

func TestNormalizeDraftTextPreservesNewlines(t *testing.T) {
	raw := "第一段。\n\n第二段。"
	got := NormalizeDraftText(raw)
	if got != raw {
		t.Fatalf("got %q, want %q", got, raw)
	}
}

func TestHumanizeDraftLineBreaks(t *testing.T) {
	raw := "我懂你的感受。之前我們家也遇過類似狀況。後來換了無香的才比較舒服。希望你有找到適合的。"
	got := NormalizeDraftText(raw)
	if !containsNewline(got) {
		t.Fatalf("expected paragraph breaks, got %q", got)
	}
}

func TestNormalizeDraftTextShortSingleParagraph(t *testing.T) {
	raw := "加油，會好的。"
	got := NormalizeDraftText(raw)
	if got != raw {
		t.Fatalf("got %q, want %q", got, raw)
	}
}

func containsNewline(s string) bool {
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' {
			return true
		}
	}
	return false
}
