Tests that the response is serialized as JSONP and Content-Type is set to application/javascript
(t *testing.T)
| 1072 | // Tests that the response is serialized as JSONP |
| 1073 | // and Content-Type is set to application/javascript |
| 1074 | func TestContextRenderJSONP(t *testing.T) { |
| 1075 | w := httptest.NewRecorder() |
| 1076 | c, _ := CreateTestContext(w) |
| 1077 | c.Request, _ = http.NewRequest(http.MethodGet, "http://example.com/?callback=x", nil) |
| 1078 | |
| 1079 | c.JSONP(http.StatusCreated, H{"foo": "bar"}) |
| 1080 | |
| 1081 | assert.Equal(t, http.StatusCreated, w.Code) |
| 1082 | assert.Equal(t, "x({\"foo\":\"bar\"});", w.Body.String()) |
| 1083 | assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type")) |
| 1084 | } |
| 1085 | |
| 1086 | // Tests that the response is serialized as JSONP |
| 1087 | // and Content-Type is set to application/json |
nothing calls this directly
no test coverage detected