package movementtest import ( "strings" "testing" movement "amadan.net/carlos/movement/internal/movement" ) // The name placeholder changes with the position somebody picked, so each // page has to serve its own and not another's. Getting this wrong would be // invisible in a stylesheet and obvious to a visitor. func TestEachStancePageCarriesItsOwnNamePlaceholder(t *testing.T) { h := newApp(t) pages := map[string]movement.Stance{ "/no-ai": movement.StanceNever, "/uneasy": movement.StanceCurious, "/all-in": movement.StanceEnthusiast, } for path, stance := range pages { body := get(t, h, path).Body.String() mine := movement.T("form.name.placeholder." + string(stance)) if !strings.Contains(body, mine) { t.Errorf("%s is missing its own name placeholder %q", path, mine) } for _, other := range movement.Stances { if other == stance { continue } theirs := movement.T("form.name.placeholder." + string(other)) if theirs != mine && strings.Contains(body, theirs) { t.Errorf("%s carries %q, which belongs to the %s page", path, theirs, other) } } } }