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

Function TestContextJSONPBlob

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

Source from the content-addressed store, hash-verified

327}
328
329func TestContextJSONPBlob(t *testing.T) {
330 e := New()
331 rec := httptest.NewRecorder()
332 req := httptest.NewRequest(http.MethodGet, "/", nil)
333 c := e.NewContext(req, rec)
334
335 callback := "callback"
336 data, err := json.Marshal(user{ID: 1, Name: "Jon Snow"})
337 assert.NoError(t, err)
338 err = c.JSONPBlob(http.StatusOK, callback, data)
339 if assert.NoError(t, err) {
340 assert.Equal(t, http.StatusOK, rec.Code)
341 assert.Equal(t, MIMEApplicationJavaScriptCharsetUTF8, rec.Header().Get(HeaderContentType))
342 assert.Equal(t, callback+"("+userJSON+");", rec.Body.String())
343 }
344}
345
346func TestContextXML(t *testing.T) {
347 e := New()

Callers

nothing calls this directly

Calls 6

JSONPBlobMethod · 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…