telegraph/content_test.go

29 lines
724 B
Go
Raw Permalink Normal View History

package telegraph_test
2019-07-24 08:03:29 +00:00
import (
"testing"
"github.com/stretchr/testify/assert"
"gitlab.com/toby3d/telegraph"
2019-07-24 08:03:29 +00:00
)
func TestContentFormat(t *testing.T) {
t.Run("invalid", func(t *testing.T) {
_, err := telegraph.ContentFormat(42)
assert.EqualError(t, telegraph.ErrInvalidDataType, err.Error())
2019-07-24 08:03:29 +00:00
})
t.Run("valid", func(t *testing.T) {
t.Run("string", func(t *testing.T) {
validContentDOM, err := telegraph.ContentFormat(`<p>Hello, World!</p>`)
2019-07-24 08:03:29 +00:00
assert.NoError(t, err)
assert.NotEmpty(t, validContentDOM)
})
t.Run("bytes", func(t *testing.T) {
validContentDOM, err := telegraph.ContentFormat([]byte(`<p>Hello, World!</p>`))
2019-07-24 08:03:29 +00:00
assert.NoError(t, err)
assert.NotEmpty(t, validContentDOM)
})
})
}