goparsify/html/html_test.go

20 lines
489 B
Go
Raw Normal View History

2017-08-06 09:02:39 +02:00
package html
import (
2017-08-13 09:30:10 +02:00
"os"
2017-08-06 09:02:39 +02:00
"testing"
"github.com/stretchr/testify/require"
2021-05-07 21:52:01 +02:00
"kesim.org/goparsify"
2017-08-06 09:02:39 +02:00
)
func TestParse(t *testing.T) {
2017-08-13 09:30:10 +02:00
goparsify.EnableLogging(os.Stdout)
2017-08-10 16:08:08 +02:00
result, err := parse(`<body>hello <p color="blue">world</p></body>`)
2017-08-06 09:02:39 +02:00
require.NoError(t, err)
2017-08-10 16:08:08 +02:00
require.Equal(t, htmlTag{Name: "body", Attributes: map[string]string{}, Body: []interface{}{
2017-08-06 09:02:39 +02:00
"hello ",
2017-08-10 16:08:08 +02:00
htmlTag{Name: "p", Attributes: map[string]string{"color": "blue"}, Body: []interface{}{"world"}},
2017-08-06 09:02:39 +02:00
}}, result)
}