package handlers

import (
	"testing"

	"leadb2b.org/internal/api"
)

func TestRegisterErrorMessageAPIConflict(t *testing.T) {
	msg := registerErrorMessage(&api.APIError{Status: 409, Message: "E-mail já cadastrado."})
	if msg != "E-mail já cadastrado." {
		t.Fatalf("msg = %q", msg)
	}
}

func TestRegisterErrorMessageFallback(t *testing.T) {
	msg := registerErrorMessage(&api.APIError{Status: 500, Message: ""})
	if msg != "Não foi possível conectar ao serviço. Verifique sua conexão e tente novamente." {
		t.Fatalf("msg = %q", msg)
	}
}
