github.com/status-im/status-go@v1.1.0/images/initials_test.go (about)

     1  package images
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestExtractInitials(t *testing.T) {
     8  	testCases := []struct {
     9  		fullName         string
    10  		amountInitials   int
    11  		expectedInitials string
    12  	}{
    13  		{"John Doe", 1, "J"},
    14  		{"John Doe", 2, "JD"},
    15  		{"John    Doe", 2, "JD"},
    16  		{"Jane ", 2, "J"},
    17  		{"Xxxx", 2, "X"},
    18  		{"", 2, ""},
    19  	}
    20  
    21  	for _, tc := range testCases {
    22  		actualInitials := ExtractInitials(tc.fullName, tc.amountInitials)
    23  		if actualInitials != tc.expectedInitials {
    24  			t.Errorf("Unexpected result for %q with %d initials, expected %q but got %q", tc.fullName, tc.amountInitials, tc.expectedInitials, actualInitials)
    25  		}
    26  	}
    27  }