summaryrefslogtreecommitdiff
path: root/web/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/server_test.go')
-rw-r--r--web/server_test.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/web/server_test.go b/web/server_test.go
index 8e4c568..23270ed 100644
--- a/web/server_test.go
+++ b/web/server_test.go
@@ -161,12 +161,23 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) {
assert.Contains(t, body, `id="ride-profile"`)
assert.Contains(t, body, `id="ride-profile-chart"`)
assert.Contains(t, body, `id="ride-map"`)
- assert.Contains(t, body, "pointermove")
- assert.Contains(t, body, "circleMarker")
- assert.Contains(t, body, "crossing.passElevationM")
- assert.Contains(t, body, "const labelY = plot.top - 6")
+ assert.Contains(t, body, `<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" defer></script>`)
+ assert.Contains(t, body, `<script src="/static/ride-detail.js" defer></script>`)
+ assert.NotContains(t, body, "pointermove")
+
+ staticRequest := httptest.NewRequest(http.MethodGet, "/static/ride-detail.js", nil)
+ staticResponse := httptest.NewRecorder()
+ server.Handler().ServeHTTP(staticResponse, staticRequest)
+
+ script := staticResponse.Body.String()
+ assert.Equal(t, http.StatusOK, staticResponse.Code)
+ assert.Equal(t, "text/javascript; charset=utf-8", staticResponse.Header().Get("Content-Type"))
+ assert.Contains(t, script, "pointermove")
+ assert.Contains(t, script, "circleMarker")
+ assert.Contains(t, script, "crossing.passElevationM")
+ assert.Contains(t, script, "const labelY = plot.top - 6")
assert.Contains(t, body, "leaflet@1.9.4/dist/leaflet.js")
- assert.Contains(t, body, "tile.openstreetmap.org/{z}/{x}/{y}.png")
+ assert.Contains(t, script, "tile.openstreetmap.org/{z}/{x}/{y}.png")
assert.Contains(t, body, `"type":"FeatureCollection"`)
assert.Contains(t, body, `"type":"LineString"`)
assert.Contains(t, body, `"coordinates":[[5,43]`)