diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-11 22:19:22 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-11 22:19:22 +0200 |
| commit | 991ab2f179b2d84e8b0ce6d0634b4033f20e4b86 (patch) | |
| tree | 225d8b5e8b46245ece9f2d8002b7db47727c3ee3 /web/server_test.go | |
| parent | 690ced7aea43c1187a66d9f7ef813bd6daa13195 (diff) | |
refactor(web): extract ride detail script
Diffstat (limited to 'web/server_test.go')
| -rw-r--r-- | web/server_test.go | 21 |
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]`) |