MCPcopy
hub / github.com/gin-gonic/gin / TestRenderJsonpJSONError2

Function TestRenderJsonpJSONError2

render/render_test.go:219–232  ·  render/render_test.go::TestRenderJsonpJSONError2
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func TestRenderJsonpJSONError2(t *testing.T) {
220 w := httptest.NewRecorder()
221 data := map[string]any{
222 "foo": "bar",
223 }
224 (JsonpJSON{"", data}).WriteContentType(w)
225 assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type"))
226
227 e := (JsonpJSON{"", data}).Render(w)
228 require.NoError(t, e)
229
230 assert.JSONEq(t, "{\"foo\":\"bar\"}", w.Body.String())
231 assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type"))
232}
233
234func TestRenderJsonpJSONFail(t *testing.T) {
235 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 5

WriteContentTypeMethod · 0.65
RenderMethod · 0.65
StringMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected