-
Notifications
You must be signed in to change notification settings - Fork 6
/
h_test.go
executable file
·39 lines (25 loc) · 1.18 KB
/
h_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
package vn_test
import (
"testing"
"github.com/stretchr/testify/assert"
)
import vn "github.com/mfrachet/go-vdom-wasm"
func TestH_WithText(t *testing.T) {
expected := vn.NewNode("div", &vn.Attrs{Props: &vn.Props{}, Events: &vn.Ev{}}, nil, vn.NewTextnode("Hello world"), nil, nil)
vNode := vn.H("div", "Hello world")
assert.Equal(t, expected, vNode)
}
func TestH_WithChildren(t *testing.T) {
child := vn.H("span", "Hello world")
expected := vn.NewNode("div", &vn.Attrs{Props: &vn.Props{}, Events: &vn.Ev{}}, vn.Children{child}, nil, nil, nil)
vNode := vn.H("div", vn.Children{child})
assert.Equal(t, expected, vNode)
}
func TestH_WithAttributes(t *testing.T) {
exectedWithoutAttrs := vn.NewNode("div", &vn.Attrs{Props: &vn.Props{}, Events: &vn.Ev{}}, nil, vn.NewTextnode("Hello world"), nil, nil)
vNodeWithoutAttrs := vn.H("div", "Hello world")
assert.Equal(t, exectedWithoutAttrs, vNodeWithoutAttrs)
exectedWithAttrs := vn.NewNode("div", &vn.Attrs{Props: &vn.Props{"class": "navbar"}, Events: &vn.Ev{}}, nil, vn.NewTextnode("Hello world"), nil, nil)
vNodeWithAttrs := vn.H("div", &vn.Props{"class": "navbar"}, "Hello world")
assert.Equal(t, exectedWithAttrs, vNodeWithAttrs)
}