-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards_template_test.go
68 lines (63 loc) · 1.35 KB
/
cards_template_test.go
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
package counters
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCardTemplate(t *testing.T) {
template := &CardsTemplate{
Scaling: 1.5,
Settings: Settings{
Width: 800,
Height: 600,
StrokeWidth: floatP(2),
BackgroundColor: stringP("white"),
FontColorS: "black",
FontPath: "assets/freesans.ttf",
},
Cards: []Card{
{
Settings: Settings{
BackgroundColor: stringP("lightgrey"),
},
Areas: []Counter{
{
Settings: Settings{
Height: 50,
BackgroundColor: stringP("black"),
},
Texts: []Text{
{
Settings: Settings{StrokeWidth: floatP(1)},
String: "Area text",
},
},
},
},
Images: []Image{
{
Settings: Settings{Position: 11},
Path: "assets/binoculars.png",
Scale: 0.2,
},
},
Texts: []Text{
{
Settings: Settings{StrokeWidth: floatP(1)},
String: "Full card text",
},
},
},
},
}
byt, err := json.Marshal(template)
if assert.NoError(t, err) {
newTempl, err := ParseCardTemplate(byt)
if assert.NoError(t, err) {
canvas, err := newTempl.Canvas(&newTempl.Settings, newTempl.Settings.Width, newTempl.Settings.Height)
if assert.NoError(t, err) {
assert.NotNil(t, canvas)
}
}
}
}