package phraser import ( "math/rand" "strings" "testing" ) // The confirmation family has the strictest constraints of the six, so they are // tested rather than left to the doc comment (Vikunja #505). func TestConfirmFamilyLoads(t *testing.T) { c, err := LoadConfirms(rand.NewSource(1)) if err != nil { t.Fatalf("LoadConfirms: %v", err) } if got := len(c.Variants()); got != len(confirmKeys) { t.Errorf("variants %d, want %d: every entry is fixed at one wording", got, len(confirmKeys)) } } // A propose line that lost {name} would tell him a command is not allowed // without saying which one, which is the whole content of the line. func TestEveryProposeLineNamesTheVerb(t *testing.T) { for _, key := range []string{ProposeFailed, ProposeNew, ProposeAlready} { got := C(key, map[string]string{"name": "перезагрузи"}) if !strings.Contains(got, "перезагрузи") { t.Errorf("%s: %q does not name the verb", key, got) } } } // A spoken yes does not accept a routine. The line has to keep saying where the // acceptance happens, or he hears agreement and gets no reminders. func TestRoutineYesStillPointsAtThePage(t *testing.T) { got := C(ConfirmRoutineAuthed, nil) if !strings.Contains(got, "рутин") { t.Errorf("%q does not name the routines page", got) } } // The floor answers when the file will not load, so the deck can never leave a // confirmed act with nothing to say. func TestConfirmFloorAnswersWithoutTheFile(t *testing.T) { var c *Confirms if got := c.Say(ConfirmCancelled, nil); got != confirmFloor[ConfirmCancelled] { t.Errorf("nil deck: %q, want the floor line", got) } if got := c.Say(ProposeFailed, map[string]string{"name": "стоп"}); !strings.Contains(got, "стоп") { t.Errorf("nil deck: %q does not name the verb", got) } }