(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestRenderJSON(t *testing.T) { |
| 27 | w := httptest.NewRecorder() |
| 28 | data := map[string]any{ |
| 29 | "foo": "bar", |
| 30 | "html": "<b>", |
| 31 | } |
| 32 | |
| 33 | (JSON{data}).WriteContentType(w) |
| 34 | assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type")) |
| 35 | |
| 36 | err := (JSON{data}).Render(w) |
| 37 | |
| 38 | require.NoError(t, err) |
| 39 | assert.JSONEq(t, "{\"foo\":\"bar\",\"html\":\"\\u003cb\\u003e\"}", w.Body.String()) |
| 40 | assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type")) |
| 41 | } |
| 42 | |
| 43 | func TestRenderJSONError(t *testing.T) { |
| 44 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected
searching dependent graphs…