-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude_test.go
More file actions
103 lines (84 loc) · 1.88 KB
/
Copy pathinclude_test.go
File metadata and controls
103 lines (84 loc) · 1.88 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package remark
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Include_String(t *testing.T) {
t.Parallel()
r := require.New(t)
include := Include{
Generic: &Generic{
Attributes: Attributes{
"src": "test.md",
},
Children: Tags{
String("This is included content"),
String("More content"),
},
},
}
result := include.String()
r.Equal("This is included content More content", result)
}
func Test_Include_String_Empty(t *testing.T) {
t.Parallel()
r := require.New(t)
include := Include{
Generic: &Generic{
Attributes: Attributes{
"src": "test.md",
},
Children: Tags{},
},
}
result := include.String()
r.Equal("", result)
}
func Test_Include_String_WithNilGeneric(t *testing.T) {
t.Parallel()
r := require.New(t)
include := Include{
Generic: nil,
}
// This should panic or handle gracefully
r.Panics(func() {
_ = include.String()
})
}
func Test_Include_AsTag(t *testing.T) {
t.Parallel()
r := require.New(t)
include := Include{
Generic: &Generic{
Name: "include",
Attributes: Attributes{"src": "test.md"},
Children: Tags{String("content")},
},
}
// Test that Include implements Tag interface
var tag Tag = &include
r.NotNil(tag)
}
func Test_Include_WithComplexChildren(t *testing.T) {
t.Parallel()
r := require.New(t)
child1 := NewGeneric("p")
child1.Children = append(child1.Children, String("Paragraph content"))
child2 := NewGeneric("div")
child2.Set("class", "container")
child2.Children = append(child2.Children, String("Div content"))
include := Include{
Generic: &Generic{
Attributes: Attributes{
"src": "complex.md",
},
Children: Tags{child1, child2},
},
}
result := include.String()
r.Contains(result, "Paragraph content")
r.Contains(result, "Div content")
r.Contains(result, "<p>")
r.Contains(result, "<div")
r.Contains(result, `class="container"`)
}