ECL, default scale, and preferred alignment entries
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user