github.com/blend/go-sdk@v1.20220411.3/stringutil/slugify_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package stringutil
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/blend/go-sdk/assert"
    14  )
    15  
    16  func TestSlugify(t *testing.T) {
    17  	assert := assert.New(t)
    18  
    19  	testCases := [...]struct {
    20  		Input, Expected string
    21  	}{
    22  		{"foo", "foo"},
    23  		{"Foo", "foo"},
    24  		{"f00", "f00"},
    25  		{"foo-bar", "foo-bar"},
    26  		{"foo & bar", "foo-bar"},
    27  		{"foo--bar", "foo-bar"},
    28  		{"foo-.bar", "foo-bar"},
    29  		{"foo bar", "foo-bar"},
    30  		{"foo  bar", "foo-bar"},
    31  		{"foo\tbar", "foo-bar"},
    32  		{"foo\nbar", "foo-bar"},
    33  		{"foo\t\nbar", "foo-bar"},
    34  		{"foo\t\nbar\t\n", "foo-bar-"},
    35  		{"Mt. Tam", "mt-tam"},
    36  	}
    37  
    38  	for _, tc := range testCases {
    39  		assert.Equal(tc.Expected, Slugify(tc.Input))
    40  	}
    41  }