package router

import "testing"

func TestThinSingleTokenThinsBareNominals(t *testing.T) {
	// The case the rule exists for: one noun, no way to tell what was asked.
	for _, w := range []string{"вода", "бэкап", "нексус", "почта", "backup"} {
		if !thinSingleToken(w) {
			t.Errorf("thinSingleToken(%q) = false, want true", w)
		}
	}
}

func TestThinSingleTokenSparesCompleteUtterances(t *testing.T) {
	// Regression: every one of these used to be answered with
	// "не совсем поняла — можешь переформулировать?".
	for _, w := range []string{
		"привет", "Привет!", "спасибо", "да", "нет", "стоп", "hello", "yes",
		"поужинал", "проснулась", "устал", "выспался", "договорились",
	} {
		if thinSingleToken(w) {
			t.Errorf("thinSingleToken(%q) = true, want false", w)
		}
	}
}

func TestThinSingleTokenIgnoresMultiWord(t *testing.T) {
	for _, s := range []string{"выпил воды", "что там с бэкапом", ""} {
		if thinSingleToken(s) {
			t.Errorf("thinSingleToken(%q) = true, want false", s)
		}
	}
}

func TestCompleteParsedSingleVerbFactNeedsGrammarAndAKey(t *testing.T) {
	if !completeParsedSingleVerbFact(Decision{
		Intent: IntentFact, Utterance: "поужинал", Slots: Slots{Key: "meal", HasKey: true},
	}) {
		t.Fatal("a parsed one-word Russian fact was not complete")
	}
	for _, decision := range []Decision{
		{Intent: IntentFact, Utterance: "вода", Slots: Slots{Key: "water", HasKey: true}},
		{Intent: IntentFact, Utterance: "поужинал"},
		{Intent: IntentQuery, Utterance: "поужинал", Slots: Slots{Key: "meal", HasKey: true}},
	} {
		if completeParsedSingleVerbFact(decision) {
			t.Errorf("incomplete decision was accepted: %+v", decision)
		}
	}
}
