1package theme23import (4 "os"5 "regexp"6 "testing"7)89// pictureFamily is a row of the table of the docs pictures' color10// families in docs/contributing/site.md: | Family | `dark` | `light` |.11var pictureFamily = regexp.MustCompile("(?m)^\\| ([^|`]+?) \\| `([^`]+)` \\| `([^`]+)` \\|")1213// The schemes the docs' recordings and stills are drawn in are built-in14// schemes under the names VHS knows them by, dark and light as the table15// says, with text that reads on their background as they are, and 012's16// theme in them readable.17func TestPictureSchemes(t *testing.T) {18 src, err := os.ReadFile("../../../docs/contributing/site.md")19 if err != nil {20 t.Fatal(err)21 }22 rows := pictureFamily.FindAllStringSubmatch(string(src), -1)23 if len(rows) == 0 {24 t.Fatal("no families table in site.md")25 }26 for _, row := range rows {27 for _, s := range []struct {28 name string29 dark bool30 }{{row[2], true}, {row[3], false}} {31 p, err := Lookup(s.name, "")32 if err != nil || p.Name != s.name {33 t.Errorf("%s: no built-in scheme named %q (%q, %v)", row[1], s.name, p.Name, err)34 continue35 }36 if p.Dark != s.dark {37 t.Errorf("%s: %s is dark %v", row[1], s.name, p.Dark)38 }39 requireContrast(t, s.name, "its text", p.Foreground, p.Background, minText)40 requireReadable(t, s.name, FromPalette(p))41 }42 }43}