template testing helpers
This commit is contained in:
parent
df33164b08
commit
1c533926ca
5 changed files with 84 additions and 34 deletions
|
@ -1,31 +1,20 @@
|
|||
package components_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"testing"
|
||||
|
||||
"git.sapphic.engineer/roleypoly/v4/presentation"
|
||||
"git.sapphic.engineer/roleypoly/v4/templates"
|
||||
"git.sapphic.engineer/roleypoly/v4/templates/templatetesting"
|
||||
"git.sapphic.engineer/roleypoly/v4/types"
|
||||
"git.sapphic.engineer/roleypoly/v4/types/fixtures"
|
||||
"git.sapphic.engineer/roleypoly/v4/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var (
|
||||
Templates = template.Must(template.ParseFS(templates.FS, "components/*.html"))
|
||||
)
|
||||
|
||||
func renderRole(t *testing.T, c *types.Category, r *types.Role, s bool) string {
|
||||
data := presentation.Role(c, r, s)
|
||||
buf := bytes.Buffer{}
|
||||
err := Templates.ExecuteTemplate(&buf, "role.html", data)
|
||||
if err != nil {
|
||||
t.Fatal("template failed to render", err)
|
||||
}
|
||||
return buf.String()
|
||||
return templatetesting.Template(t, "components/role", data)
|
||||
}
|
||||
|
||||
func TestRole(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue