rastrillo / fiesta Public

Clone
git clone https://amadan.net/rastrillo/fiesta

Plain git — no account needed to clone.

Download

Download this file

1package gallery
2
3import (
4 "fmt"
5 "strings"
6 "testing"
7)
8
9// TestTheColumnPreviewRestsShorterThanItOpens: the column's footer
10// menus open downward under the page, and a box that always held them
11// open showed about 300px of nothing under the page at rest. So the
12// column has a rest height, and every rest height is written beside
13// the open one for view.js to switch to: under the open height on
14// Desktop and on Mobile in every locale, since a rest height at or
15// over the open one could only hide a short open box. A key without
16// one carries no rest height at all, so view.js leaves it alone.
17func TestTheColumnPreviewRestsShorterThanItOpens(t *testing.T) {
18 column := "layout-column/" + mustEntry(t, "layout-column").Default
19 if _, ok := previewRestHeights[column]; !ok {
20 t.Errorf("%s has no rest height; its box holds the open footer menus at rest", column)
21 }
22 m := manifest(t)
23 for key, rest := range previewRestHeights {
24 name, state, _ := strings.Cut(key, "/")
25 if e, ok := m.Entry(name); !ok || !hasState(e, state) {
26 t.Errorf("previewRestHeights[%q] names no example state", key)
27 continue
28 }
29 for _, locale := range Locales {
30 open, openMobile := previewHeightsFor(locale, key)
31 if rest.Desktop >= open || rest.Mobile >= openMobile {
32 t.Errorf("%s in %s rests at %d, %d and opens at %d, %d; the rest height must be under the open one", key, locale, rest.Desktop, rest.Mobile, open, openMobile)
33 }
34 want := fmt.Sprintf("--ds-hr: %dpx; --ds-hmr: %dpx", rest.Desktop, rest.Mobile)
35 if got := string(previewStyle(locale, key)); !strings.Contains(got, want) {
36 t.Errorf("%s in %s: the widget's style is %q, want it to carry %q", key, locale, got, want)
37 }
38 }
39 }
40 for _, key := range []string{"button/default", "dropdown/" + mustEntry(t, "dropdown").Default} {
41 if got := string(previewStyle("en", key)); strings.Contains(got, "--ds-hr") {
42 t.Errorf("%s has no rest height and its style %q carries one", key, got)
43 }
44 }
45}
46