This commit is contained in:
@@ -72,7 +72,7 @@ func TestDashboardRendersFullTemplPage(t *testing.T) {
|
||||
NewHandler(service).ServeHTTP(response, request)
|
||||
|
||||
body := response.Body.String()
|
||||
for _, expected := range []string{"<!doctype html>", "DARANO", "1,234", "abc123", "htmx.org@2.0.10", "class=\"mark\" src=\"/favicon.ico\"", "#F5F5F5", "#DFF1F1", "#BBD5DA", "#FF0000"} {
|
||||
for _, expected := range []string{"<!doctype html>", "DARANO", "1,234", "abc123", "htmx.org@2.0.10", "src=\"/theme.js\"", "data-theme-toggle", "html[data-theme=\"dark\"]", "class=\"mark\" src=\"/favicon.ico\"", "#F5F5F5", "#DFF1F1", "#BBD5DA", "#FF0000"} {
|
||||
if !strings.Contains(body, expected) {
|
||||
t.Fatalf("response did not contain %q", expected)
|
||||
}
|
||||
@@ -183,6 +183,21 @@ func TestFaviconIsServedFromEmbeddedBrandAsset(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestThemeScriptIsServedFromEmbeddedAsset(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "/theme.js", nil)
|
||||
response := httptest.NewRecorder()
|
||||
|
||||
NewHandler(&explorerStub{}).ServeHTTP(response, request)
|
||||
|
||||
body := response.Body.String()
|
||||
if response.Code != http.StatusOK || !strings.Contains(body, "localStorage") || !strings.Contains(body, "prefers-color-scheme") {
|
||||
t.Fatalf("unexpected theme script response: status=%d body=%s", response.Code, body)
|
||||
}
|
||||
if !strings.Contains(response.Header().Get("Content-Type"), "javascript") {
|
||||
t.Fatalf("unexpected theme script content type: %s", response.Header().Get("Content-Type"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTransactionHTMXRequestRendersOnlyExplorerContent(t *testing.T) {
|
||||
service := &explorerStub{transaction: []ledger.Journal{{
|
||||
ID: "journal-1", EffectKind: "withdrawal",
|
||||
|
||||
Reference in New Issue
Block a user