package social

import (
	"errors"
	"testing"
)

func TestCleanAllowsOrdinaryChat(t *testing.T) {
	clean := []string{
		"",
		"nice move!",
		"gg wp",
		"хороший ход, поздравляю",
		"unlucky draw this round",
		"I scored 42 points",
		"only 6 digits here: 123456",
		"see you at 5",
		"three vowels in my rack",
		"well played :)",
	}
	for _, body := range clean {
		if err := Clean(body); err != nil {
			t.Errorf("Clean(%q) = %v, want nil", body, err)
		}
	}
}

func TestCleanRejectsLinksEmailsPhones(t *testing.T) {
	forbidden := []string{
		// Plain links and bare domains.
		"http://evil.example.com",
		"visit https://x.io/abc now",
		"join discord.gg/xyzqwer",
		"check scrabblecheat.com",
		// Emails, plain and obfuscated.
		"mail me a@b.com",
		"john at gmail dot com",
		"j0hn at gma1l dot c0m",
		// Obfuscated domains.
		"g00gle dot com",
		"site . com please",
		// Phone numbers, plain and grouped.
		"call 89001234567",
		"+7 900 123 45 67",
		"8 (900) 123-45-67",
		"my number is 1234567",
	}
	for _, body := range forbidden {
		if err := Clean(body); !errors.Is(err, ErrForbiddenContent) {
			t.Errorf("Clean(%q) = %v, want ErrForbiddenContent", body, err)
		}
	}
}
