package utils

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestSlugify(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		expected string
	}{
		{
			name:     "simple username",
			input:    "john_doe",
			expected: "john-doe",
		},
		{
			name:     "username with spaces",
			input:    "John Doe",
			expected: "john-doe",
		},
		{
			name:     "username with special characters",
			input:    "John@Doe#123",
			expected: "johndoe123",
		},
		{
			name:     "username with multiple spaces",
			input:    "John  Doe",
			expected: "john-doe",
		},
		{
			name:     "username with underscores",
			input:    "john_doe_123",
			expected: "john-doe-123",
		},
		{
			name:     "username with mixed case",
			input:    "JohnDoe",
			expected: "johndoe",
		},
		{
			name:     "username with leading/trailing dashes",
			input:    "-john-doe-",
			expected: "john-doe",
		},
		{
			name:     "username with consecutive dashes",
			input:    "john--doe",
			expected: "john-doe",
		},
		{
			name:     "username with numbers",
			input:    "user123",
			expected: "user123",
		},
		{
			name:     "empty string",
			input:    "",
			expected: "",
		},
		{
			name:     "only special characters",
			input:    "@#$%",
			expected: "",
		},
		{
			name:     "username with accented characters",
			input:    "José",
			expected: "jose",
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			result := Slugify(tt.input)
			assert.Equal(t, tt.expected, result, "Slugify(%q) = %q, want %q", tt.input, result, tt.expected)
		})
	}
}
