| 105 | } |
| 106 | |
| 107 | func TestHTMLXHTML(t *testing.T) { |
| 108 | render := New(Options{ |
| 109 | Directory: "testdata/basic", |
| 110 | HTMLContentType: ContentXHTML, |
| 111 | }) |
| 112 | |
| 113 | var err error |
| 114 | |
| 115 | h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 116 | err = render.HTML(w, http.StatusOK, "hello", "gophers") |
| 117 | }) |
| 118 | |
| 119 | res := httptest.NewRecorder() |
| 120 | req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/foo", nil) |
| 121 | h.ServeHTTP(res, req) |
| 122 | |
| 123 | expectNil(t, err) |
| 124 | expect(t, res.Code, 200) |
| 125 | expect(t, res.Header().Get(ContentType), ContentXHTML+"; charset=UTF-8") |
| 126 | expect(t, res.Body.String(), "<h1>Hello gophers</h1>\n") |
| 127 | } |
| 128 | |
| 129 | func TestHTMLExtensions(t *testing.T) { |
| 130 | render := New(Options{ |