ECL, default scale, and preferred alignment entries

This commit is contained in:
2026-05-24 17:58:33 +02:00
parent cc9996cd69
commit a0c3c89049
9 changed files with 551 additions and 2 deletions
+40
View File
@@ -1248,6 +1248,46 @@ func TestWikiTemplateRacialOptionalFactsRenderOnlyWhenPresent(t *testing.T) {
}
}
func TestWikiTemplateFormatsPreferredAlignments(t *testing.T) {
ctx := &wikiContext{}
template := `{{alignments(PreferredAlignments)}}`
tests := []struct {
name string
value any
want string
}{
{name: "encoded list", value: "0x120C01", want: "Lawful Evil, Chaotic Good, True Neutral"},
{name: "authored list", value: []any{"le", "CG", "tn"}, want: "Lawful Evil, Chaotic Good, True Neutral"},
{name: "authored object list", value: map[string]any{"list": []any{"ce", "ne"}}, want: "Chaotic Evil, Neutral Evil"},
{name: "zero", value: 0, want: "Any"},
{name: "encoded zero", value: "0x00", want: "Any"},
{name: "null", value: nil, want: "Any"},
{name: "missing", value: nil, want: "Any"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
row := map[string]any{}
if test.name != "missing" {
row["PreferredAlignments"] = test.value
}
page := wikiTemplatePage{
PageID: "racialtypes:human",
Category: "racialtypes",
Key: "racialtypes:human",
Title: "Human",
Row: row,
}
got, err := ctx.renderWikiTemplateString("racialtypes.html", template, page)
if err != nil {
t.Fatalf("render template: %v", err)
}
if got != test.want {
t.Fatalf("expected %q, got %q", test.want, got)
}
})
}
}
func TestWikiTemplateDescriptionFiltersExtractParagraphsAndSections(t *testing.T) {
ctx := &wikiContext{}
page := wikiTemplatePage{