package threadspost

import "testing"

func TestFormatDraftTextPreservesPunctuationAndLineBreaks(t *testing.T) {
	raw := "我最近迷上自己做早餐耶！\n以前都隨便買個麵包、三明治，趕著出門。\n有沒有人也跟我一樣？"
	want := "我最近迷上自己做早餐耶！\n以前都隨便買個麵包、三明治，趕著出門。\n有沒有人也跟我一樣？"
	got := FormatDraftText(raw)
	if got != want {
		t.Fatalf("FormatDraftText() = %q, want %q", got, want)
	}
}

func TestFormatDraftTextKeepsSingleParagraph(t *testing.T) {
	raw := "第一句很好。第二句也不錯！第三句收尾？"
	want := "第一句很好。第二句也不錯！第三句收尾？"
	got := FormatDraftText(raw)
	if got != want {
		t.Fatalf("FormatDraftText() = %q, want %q", got, want)
	}
}

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

func TestFormatDraftTextPreservesEmoji(t *testing.T) {
	raw := "廚房像打完仗一樣 😂\n但看到成果就值得了"
	want := "廚房像打完仗一樣 😂\n但看到成果就值得了"
	got := FormatDraftText(raw)
	if got != want {
		t.Fatalf("FormatDraftText() = %q, want %q", got, want)
	}
}

func TestFormatDraftTextPreservesHashtag(t *testing.T) {
	raw := "今天心情不錯\n#早餐日記"
	want := "今天心情不錯\n#早餐日記"
	got := FormatDraftText(raw)
	if got != want {
		t.Fatalf("FormatDraftText() = %q, want %q", got, want)
	}
}
