More racial template entries
This commit is contained in:
@@ -1193,6 +1193,61 @@ func TestWikiTemplateCanRenderRacialFactsAndFeatListInHTML(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWikiTemplateRacialOptionalFactsRenderOnlyWhenPresent(t *testing.T) {
|
||||
ctx := &wikiContext{}
|
||||
template := `{{#if present(ECL)}}ECL={{ECL}}{{/if}}
|
||||
{{#if present(PreferredAlignments)}}Preferred={{PreferredAlignments}}{{/if}}
|
||||
{{#if present(StartLanguages)}}Start={{StartLanguages}}{{/if}}
|
||||
{{#if present(BonusLanguages)}}Bonus={{BonusLanguages}}{{/if}}`
|
||||
page := wikiTemplatePage{
|
||||
PageID: "racialtypes:human",
|
||||
Category: "racialtypes",
|
||||
Key: "racialtypes:human",
|
||||
Title: "Human",
|
||||
Row: map[string]any{
|
||||
"ECL": 0,
|
||||
"PreferredAlignments": "0x00",
|
||||
"StartLanguages": "regional",
|
||||
"BonusLanguages": "all",
|
||||
},
|
||||
}
|
||||
|
||||
got, err := ctx.renderWikiTemplateString("racialtypes.html", template, page)
|
||||
if err != nil {
|
||||
t.Fatalf("render template: %v", err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"ECL=0",
|
||||
"Preferred=0x00",
|
||||
"Start=regional",
|
||||
"Bonus=all",
|
||||
} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Fatalf("expected rendered output to contain %q:\n%s", want, got)
|
||||
}
|
||||
}
|
||||
|
||||
page.Row = map[string]any{
|
||||
"ECL": nil,
|
||||
"PreferredAlignments": "",
|
||||
"StartLanguages": "****",
|
||||
}
|
||||
got, err = ctx.renderWikiTemplateString("racialtypes.html", template, page)
|
||||
if err != nil {
|
||||
t.Fatalf("render template with absent values: %v", err)
|
||||
}
|
||||
for _, unwanted := range []string{
|
||||
"ECL=",
|
||||
"Preferred=",
|
||||
"Start=",
|
||||
"Bonus=",
|
||||
} {
|
||||
if strings.Contains(got, unwanted) {
|
||||
t.Fatalf("expected rendered output to omit %q for absent values:\n%s", unwanted, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWikiTemplateDescriptionFiltersExtractParagraphsAndSections(t *testing.T) {
|
||||
ctx := &wikiContext{}
|
||||
page := wikiTemplatePage{
|
||||
|
||||
Reference in New Issue
Block a user