MCPcopy Index your code
hub / github.com/labstack/echo / TestContextJSONP

Function TestContextJSONP

context_test.go:298–311  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

296}
297
298func TestContextJSONP(t *testing.T) {
299 e := New()
300 rec := httptest.NewRecorder()
301 req := httptest.NewRequest(http.MethodGet, "/", nil)
302 c := e.NewContext(req, rec)
303
304 callback := "callback"
305 err := c.JSONP(http.StatusOK, callback, user{ID: 1, Name: "Jon Snow"})
306 if assert.NoError(t, err) {
307 assert.Equal(t, http.StatusOK, rec.Code)
308 assert.Equal(t, MIMEApplicationJavaScriptCharsetUTF8, rec.Header().Get(HeaderContentType))
309 assert.Equal(t, callback+"("+userJSON+"\n);", rec.Body.String())
310 }
311}
312
313func TestContextJSONBlob(t *testing.T) {
314 e := New()

Callers

nothing calls this directly

Calls 6

JSONPMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
GetMethod · 0.45
HeaderMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…