feat: public API, SEO and existing surfaces
This commit is contained in:
1 parent
45fbbc33b1
commit
c390fcfe8d
103 files changed
+4476
-231
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"RenewCMS/internal/domain/localization"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLocalizationCompareTags(t *testing.T) {
|
||||
examples := []struct {
|
||||
name string
|
||||
left string
|
||||
right string
|
||||
want int
|
||||
}{
|
||||
{"same tag", "fr", "fr", 0},
|
||||
{"same default tag", "en", "en", 0},
|
||||
{"default first", "en", "de", -1},
|
||||
{"default last argument", "de", "en", 1},
|
||||
{"alphabetical before", "de", "fr", -1},
|
||||
{"alphabetical after", "fr", "de", 1},
|
||||
}
|
||||
for _, example := range examples {
|
||||
t.Run(example.name, func(t *testing.T) {
|
||||
if got := localization.CompareTags("en", example.left, example.right); got != example.want {
|
||||
t.Errorf("CompareTags(%q, %q) = %d, want %d", example.left, example.right, got, example.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizationBuildViewOrdersDefaultThenEnabledThenTag(t *testing.T) {
|
||||
rows := []localization.Row{
|
||||
{Tag: "pt", Enabled: false, Confirmed: true},
|
||||
{Tag: "fr", Enabled: true, Confirmed: true},
|
||||
{Tag: "es", Enabled: false, Confirmed: true},
|
||||
{Tag: "en", IsDefault: true, Enabled: true, Confirmed: true},
|
||||
{Tag: "de", Enabled: true, Confirmed: true},
|
||||
}
|
||||
|
||||
view := localization.BuildView(rows, map[string]localization.VersionCount{}, nil)
|
||||
|
||||
order := []string{}
|
||||
for _, language := range view.Languages {
|
||||
order = append(order, language.Lang)
|
||||
}
|
||||
if want := []string{"en", "de", "fr", "es", "pt"}; !reflect.DeepEqual(order, want) {
|
||||
t.Errorf("order = %v, want %v", order, want)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user