-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathempty_test.go
55 lines (43 loc) · 1.04 KB
/
empty_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
package hype
import (
"testing"
"github.com/gopherguides/hype/atomx"
"github.com/stretchr/testify/require"
)
func Test_IsEmptyNode(t *testing.T) {
t.Parallel()
// r := require.New(t)
// p := testParser(t, "testdata")
// const frag = `<table>
// <thead>
// <tr>
// <th></th>
// <th></th>
// </tr>
// </thead>`
// table, err := p.ParseFragment(strings.NewReader(frag))
// r.NoError(err)
fullP := NewEl(atomx.P, nil)
fullP.Nodes = append(fullP.Nodes, Text("Hello World"))
emptyP := NewEl(atomx.P, nil)
tcs := []struct {
name string
node Node
exp bool
}{
{name: "nil", node: nil, exp: true},
{name: "text", node: Text("hello"), exp: false},
{name: "empty text", node: Text(""), exp: true},
{name: "empty paragraph", node: emptyP, exp: true},
{name: "full paragraph", node: fullP, exp: false},
// {name: "empty table", node: table, exp: true},
}
for _, tc := range tcs {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
r := require.New(t)
r.Equal(tc.exp, IsEmptyNode(tc.node))
})
}
}