package router

import "testing"

func TestAmbiguousFragmentGrammarRefusesOnlyMissingReferences(t *testing.T) {
	g := AmbiguousFragmentGrammar()
	for _, utterance := range []string{
		"ну это",
		"потом",
		"это, пожалуйста",
		"the thing from earlier",
		"just that",
	} {
		decision, matched, accepted := g.Evaluate(utterance)
		if !matched || !accepted || !decision.Clarify {
			t.Errorf("%q = %+v, matched=%v accepted=%v; want a refusal", utterance, decision, matched, accepted)
		}
	}
}

func TestAmbiguousFragmentGrammarLeavesSentencesAndSocialTurnsAlone(t *testing.T) {
	g := AmbiguousFragmentGrammar()
	for _, utterance := range []string{
		"это резервный ключ",
		"сделай это",
		"напомни про это завтра",
		"пожалуйста",
		"ну привет",
		"that server is down",
	} {
		if decision, matched, accepted := g.Evaluate(utterance); matched || accepted {
			t.Errorf("%q was claimed as %+v", utterance, decision)
		}
	}
}
