Skip to content

Commit

Permalink
Confirm CSS content type is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Aug 8, 2024
1 parent 45fb450 commit ca96206
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ func TestServeFile(t *testing.T) {
assert.Equal(t, fmt.Sprintf("%s/%s\n", testDir, filePath), string(body))
}

func TestServeCSS(t *testing.T) {
testDir := "root"
filePath := "style.css"

s := &Serve{
Dir: fmt.Sprintf("testdata/%s", testDir),
}

handler := s.handler()

request := httptest.NewRequest("GET", fmt.Sprintf("/%s", filePath), nil)
recorder := httptest.NewRecorder()

handler.ServeHTTP(recorder, request)

response := recorder.Result()

assert.Equal(t, http.StatusOK, response.StatusCode)
assert.Equal(t, "text/css; charset=utf-8", response.Header.Get("Content-Type"))
}

func TestServeSubIndex(t *testing.T) {
testDir := "root"
dirPath := "sub"
Expand Down
3 changes: 3 additions & 0 deletions testdata/root/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html {
font-family: var(--sans-font);
}

0 comments on commit ca96206

Please sign in to comment.