| 327 | } |
| 328 | |
| 329 | func 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 | |
| 346 | func TestContextXML(t *testing.T) { |
| 347 | e := New() |