Tests that the response is serialized as JSONP and Content-Type is set to application/json
(t *testing.T)
| 1086 | // Tests that the response is serialized as JSONP |
| 1087 | // and Content-Type is set to application/json |
| 1088 | func TestContextRenderJSONPWithoutCallback(t *testing.T) { |
| 1089 | w := httptest.NewRecorder() |
| 1090 | c, _ := CreateTestContext(w) |
| 1091 | c.Request, _ = http.NewRequest(http.MethodGet, "http://example.com", nil) |
| 1092 | |
| 1093 | c.JSONP(http.StatusCreated, H{"foo": "bar"}) |
| 1094 | |
| 1095 | assert.Equal(t, http.StatusCreated, w.Code) |
| 1096 | assert.JSONEq(t, `{"foo":"bar"}`, w.Body.String()) |
| 1097 | assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type")) |
| 1098 | } |
| 1099 | |
| 1100 | // Tests that no JSON is rendered if code is 204 |
| 1101 | func TestContextRenderNoContentJSON(t *testing.T) { |
nothing calls this directly
no test coverage detected