-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathrender_ionic_test.go
90 lines (86 loc) · 1.71 KB
/
render_ionic_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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package flow
import (
"encoding/json"
"fmt"
"io/ioutil"
"testing"
)
var testString = `
{
"ID": "key_test",
"Fields": [{
"ID": "id_1",
"Type": "string",
"Label": "label_1",
"DefaultValue": "default_1",
"Values": null,
"Validations": [{
"Name": "constraint_1",
"Config": "constraint_1_config"
}, {
"Name": "constraint_2",
"Config": "constraint_2_config"
}],
"Properties": [{
"ID": "Property_1",
"Value": "Property_1_value"
}, {
"ID": "Property_2",
"Value": "Property_2_value"
}]
}, {
"ID": "FormField_2",
"Type": "long",
"Label": "FormField_2_label",
"DefaultValue": "",
"Values": null,
"Validations": null,
"Properties": null
}, {
"ID": "FormField_3",
"Type": "date",
"Label": "选择日期",
"DefaultValue": "",
"Values": null,
"Validations": null,
"Properties": null
}, {
"ID": "FormField_4",
"Type": "enum",
"Label": "FormField_4_label",
"DefaultValue": "FormField_4_label_default",
"Values": [{
"ID": "Value_1",
"Name": "Value_1_value"
}, {
"ID": "Value_2",
"Name": "Value_2_value"
}],
"Validations": null,
"Properties": null
}, {
"ID": "FormField_5",
"Type": "boolean",
"Label": "是否选择",
"DefaultValue": "",
"Values": null,
"Validations": null,
"Properties": null
}]
}
`
func TestRenderIonic(t *testing.T) {
var form = &NodeFormResult{}
err := json.Unmarshal([]byte(testString), form)
if err != nil {
t.Error(err.Error())
}
fmt.Println(form.ID)
render := NewIonicRenderer()
result, err := render.Render(nil, form)
if err != nil {
t.Error(err.Error())
}
fmt.Println(string(result))
ioutil.WriteFile("./tmp/index.html", result, 0644)
}