2018-08-20 10:15:31 +03:00
|
|
|
// Copyright 2018 Gin Core Team. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// +build go1.7
|
|
|
|
|
|
|
|
package render
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRenderPureJSON(t *testing.T) {
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
data := map[string]interface{}{
|
|
|
|
"foo": "bar",
|
|
|
|
"html": "<b>",
|
|
|
|
}
|
2019-04-17 17:10:21 +03:00
|
|
|
err := PureJSON(data).Render(w)
|
2018-08-20 10:15:31 +03:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, "{\"foo\":\"bar\",\"html\":\"<b>\"}\n", w.Body.String())
|
|
|
|
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
|
|
|
|
}
|