fix(viewer): serve static js with script mime type
This commit is contained in:
@@ -82,3 +82,22 @@ func TestStandaloneHandlerRootShowsUploadForm(t *testing.T) {
|
||||
t.Fatalf("expected standalone handler root to include upload form")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStaticJSUsesScriptContentType(t *testing.T) {
|
||||
handler := NewHandler(HandlerOptions{Title: "Reanimator Chart"})
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/static/view.js", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
contentType := rec.Header().Get("Content-Type")
|
||||
if !strings.Contains(contentType, "javascript") {
|
||||
t.Fatalf("Content-Type = %q, want javascript MIME type", contentType)
|
||||
}
|
||||
if !strings.Contains(rec.Body.String(), "DOMContentLoaded") {
|
||||
t.Fatalf("expected static JS asset body to be served")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user