package seasons import ( "regexp" "strings" "testing" ) func TestScriptAndProps(t *testing.T) { s := string(Script) for _, want := range []string{"function pick(", "function run(", "data-seasons", "var CSS = '';"} { if !strings.Contains(s, want) { t.Errorf("script lacks %q", want) } } if strings.Contains(s, "comes from season.css") { t.Error("the stylesheet placeholder was left in") } for _, id := range []string{"advent", "lunarnewyear", "diwali", "pride", "hanukkah", "christmas", "kwanzaa"} { if !Known(id) { t.Errorf("%s isn't a known holiday", id) } } if Known("arbor") { t.Error("made-up holiday known") } // Every prop a holiday wears has a drawing, and the drawings are plain. for _, p := range regexpAll(`prop: '([a-z]+)'`, s) { if Props[p] == nil { t.Errorf("no drawing for the %s prop", p) } } for name, svg := range Props { low := strings.ToLower(string(svg)) if strings.Contains(low, "`, `