package savestatus import ( "regexp" "strings" "testing" ) // The subtitle placement is the state under a large title (Docs on a // phone, audit finding 7): inline, quiet while things are well, in the // warning tone while retrying and the negative tone, bold, once it has // failed. Inline and floating are unchanged. func TestTheSubtitlePlacement(t *testing.T) { got := render(t, Data{State: "retrying", Placement: "subtitle", Retrying: "r"}) if !strings.Contains(got, `estilo-save-status="inline subtitle"`) { t.Errorf("the subtitle placement is not an inline variant: %s", got) } for p, want := range map[string]string{"": "inline", "inline": "inline", "floating": "floating", "subtitle": "inline subtitle"} { if m := (Data{Placement: p}).Mode(); m != want { t.Errorf("Placement %q: mode %q, want %q", p, m, want) } } src := string(CSS()) for _, re := range []string{ `\[estilo-save-status~="subtitle"\],\s*\[estilo-save-status~="subtitle"\]:not\(\[data-state="saved"\]\) \{[^}]*color: var\(--rst-text-muted\);[^}]*font-weight: inherit;`, `\[estilo-save-status~="subtitle"\]\[data-state="retrying"\] \{ color: var\(--rst-tone-warning-fg\); \}`, `\[estilo-save-status~="subtitle"\]\[data-state="failed"\] \{ color: var\(--rst-tone-negative-fg\); font-weight: 600; \}`, } { if !regexp.MustCompile(re).MatchString(src) { t.Errorf("status.css lacks %s", re) } } }