carlos / movement Public

Clone
git clone https://amadan.net/carlos/movement

Plain git — no account needed to clone.

Download

Download this file

1package movementtest
2
3import (
4 "strings"
5 "testing"
6
7 movement "amadan.net/carlos/movement/internal/movement"
8)
9
10// The name placeholder changes with the position somebody picked, so each
11// page has to serve its own and not another's. Getting this wrong would be
12// invisible in a stylesheet and obvious to a visitor.
13func TestEachStancePageCarriesItsOwnNamePlaceholder(t *testing.T) {
14 h := newApp(t)
15
16 pages := map[string]movement.Stance{
17 "/no-ai": movement.StanceNever,
18 "/uneasy": movement.StanceCurious,
19 "/all-in": movement.StanceEnthusiast,
20 }
21
22 for path, stance := range pages {
23 body := get(t, h, path).Body.String()
24 mine := movement.T("form.name.placeholder." + string(stance))
25
26 if !strings.Contains(body, mine) {
27 t.Errorf("%s is missing its own name placeholder %q", path, mine)
28 }
29 for _, other := range movement.Stances {
30 if other == stance {
31 continue
32 }
33 theirs := movement.T("form.name.placeholder." + string(other))
34 if theirs != mine && strings.Contains(body, theirs) {
35 t.Errorf("%s carries %q, which belongs to the %s page",
36 path, theirs, other)
37 }
38 }
39 }
40}
41