-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemplate_load_options_test.go
More file actions
78 lines (54 loc) · 1.67 KB
/
Copy pathtemplate_load_options_test.go
File metadata and controls
78 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package vuego_test
import (
"bytes"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/titpetric/vuego"
)
func TestLoadWithLessProcessor(t *testing.T) {
root := os.DirFS("testdata")
tpl := vuego.NewFS(root, vuego.WithLessProcessor())
require.NotNil(t, tpl)
}
func TestLoadWithMultipleProcessors(t *testing.T) {
root := os.DirFS("testdata")
tpl := vuego.NewFS(root, vuego.WithLessProcessor(), vuego.WithLessProcessor())
require.NotNil(t, tpl)
}
func TestLoadWithoutProcessors(t *testing.T) {
root := os.DirFS("testdata")
tpl := vuego.NewFS(root)
require.NotNil(t, tpl)
}
func TestTemplateFuncs(t *testing.T) {
root := os.DirFS("testdata")
funcMap := vuego.FuncMap{
"customFunc": func(s string) string {
return "custom: " + s
},
}
tpl := vuego.NewFS(root, vuego.WithFuncs(funcMap))
// Verify template is created
require.NotNil(t, tpl)
}
func TestTemplateChaining(t *testing.T) {
root := os.DirFS("testdata")
tpl := vuego.NewFS(root, vuego.WithLessProcessor(), vuego.WithFuncs(vuego.FuncMap{"test": func() string { return "test" }}))
// Verify chaining works
result := tpl.Assign("key", "value")
require.Equal(t, tpl, result)
require.Equal(t, "value", tpl.Get("key"))
}
func TestLoadTemplateRender(t *testing.T) {
root := os.DirFS("testdata")
tpl := vuego.NewFS(root, vuego.WithLessProcessor())
// Assign required attributes - Button component requires name, variant, and title
tpl.Assign("name", "TestButton").
Assign("variant", "primary").
Assign("title", "Click me")
var buf bytes.Buffer
err := tpl.Load("pages/components/Button.vuego").Render(t.Context(), &buf)
require.NoError(t, err)
require.Greater(t, buf.Len(), 0)
}