nomino/config_test.go
2025-09-26 20:23:32 -05:00

31 lines
700 B
Go

package nomino
import (
"testing"
"github.com/google/uuid"
"github.com/nalgeon/be"
)
func TestNewConf(t *testing.T) {
c := NewConfig()
be.Equal(t, c.extension, ".txt")
st, _ := c.generator(&c)
_, parseErr := uuid.Parse(st)
be.Err(t, parseErr, nil)
}
func TestNewConfWithOpts(t *testing.T) {
c := NewConfig(WithoutExtension(), WithPrefix("foobar"))
be.Equal(t, c.extension, "")
be.Equal(t, c.prefix, "foobar")
}
func TestConfAddOpts(t *testing.T) {
c := Config{original: "hi"}
c2 := c.AddOptions(WithOriginalSlug("Hello, my dear"), WithPrefix("yo"))
be.Equal(t, c.prefix, "")
be.Equal(t, c.original, "hi")
be.Equal(t, c2.original, "hello-my-dear")
be.Equal(t, c2.prefix, "yo")
}