package model

import "testing"

func TestContactRequestNormalizeAndValidate(t *testing.T) {
	req := &ContactRequest{
		Name:    " Alice ",
		Email:   " alice@example.com ",
		Phone:   " +1 234 ",
		Company: " Sendico ",
		Topic:   " General question ",
		Message: " Hello team ",
	}

	req.Normalize()
	if err := req.Validate(); err != nil {
		t.Fatalf("expected request to be valid, got error: %v", err)
	}

	if req.Name != "Alice" || req.Email != "alice@example.com" || req.Phone != "+1 234" || req.Company != "Sendico" || req.Topic != "General question" || req.Message != "Hello team" {
		t.Fatalf("normalize failed: %+v", req)
	}
}

func TestContactRequestValidateMissing(t *testing.T) {
	req := &ContactRequest{}
	req.Normalize()
	if err := req.Validate(); err == nil {
		t.Fatalf("expected validation error for empty request")
	}
}
