github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/render/string_test.go (about)

     1  package render_test
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  
     7  	"github.com/gobuffalo/buffalo/render"
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_String(t *testing.T) {
    12  	r := require.New(t)
    13  
    14  	j := render.New(render.Options{}).String
    15  
    16  	re := j("<%= name %>")
    17  	r.Equal("text/plain; charset=utf-8", re.ContentType())
    18  
    19  	var examples = []string{"Mark", "Jém"}
    20  	for _, example := range examples {
    21  		example := example
    22  		bb := &bytes.Buffer{}
    23  		err := re.Render(bb, map[string]interface{}{"name": example})
    24  		r.NoError(err)
    25  		r.Equal(example, bb.String())
    26  	}
    27  
    28  }