| 1 | package savestatus |
| 2 | |
| 3 | import ( |
| 4 | "regexp" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // The subtitle placement is the state under a large title (Docs on a |
| 10 | // phone, audit finding 7): inline, quiet while things are well, in the |
| 11 | // warning tone while retrying and the negative tone, bold, once it has |
| 12 | // failed. Inline and floating are unchanged. |
| 13 | func TestTheSubtitlePlacement(t *testing.T) { |
| 14 | got := render(t, Data{State: "retrying", Placement: "subtitle", Retrying: "r"}) |
| 15 | if !strings.Contains(got, `estilo-save-status="inline subtitle"`) { |
| 16 | t.Errorf("the subtitle placement is not an inline variant: %s", got) |
| 17 | } |
| 18 | for p, want := range map[string]string{"": "inline", "inline": "inline", "floating": "floating", "subtitle": "inline subtitle"} { |
| 19 | if m := (Data{Placement: p}).Mode(); m != want { |
| 20 | t.Errorf("Placement %q: mode %q, want %q", p, m, want) |
| 21 | } |
| 22 | } |
| 23 | src := string(CSS()) |
| 24 | for _, re := range []string{ |
| 25 | `\[estilo-save-status~="subtitle"\],\s*\[estilo-save-status~="subtitle"\]:not\(\[data-state="saved"\]\) \{[^}]*color: var\(--rst-text-muted\);[^}]*font-weight: inherit;`, |
| 26 | `\[estilo-save-status~="subtitle"\]\[data-state="retrying"\] \{ color: var\(--rst-tone-warning-fg\); \}`, |
| 27 | `\[estilo-save-status~="subtitle"\]\[data-state="failed"\] \{ color: var\(--rst-tone-negative-fg\); font-weight: 600; \}`, |
| 28 | } { |
| 29 | if !regexp.MustCompile(re).MatchString(src) { |
| 30 | t.Errorf("status.css lacks %s", re) |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | |