package connector

import "testing"

func TestOutOfAppKind(t *testing.T) {
	out := []string{"your_turn", "game_over", "nudge", "match_found", "notify"}
	for _, k := range out {
		if !OutOfAppKind(k) {
			t.Errorf("OutOfAppKind(%q) = false, want true", k)
		}
	}
	for _, k := range []string{"opponent_moved", "chat_message", "", "unknown"} {
		if OutOfAppKind(k) {
			t.Errorf("OutOfAppKind(%q) = true, want false", k)
		}
	}
}

func TestDeliverToTarget(t *testing.T) {
	cases := []struct {
		name       string
		externalID string
		inAppOnly  bool
		want       bool
	}{
		{"telegram + opted in", "12345", false, true},
		{"in-app only suppresses", "12345", true, false},
		{"no telegram identity", "", false, false},
		{"no identity and in-app only", "", true, false},
	}
	for _, tc := range cases {
		t.Run(tc.name, func(t *testing.T) {
			if got := DeliverToTarget(tc.externalID, tc.inAppOnly); got != tc.want {
				t.Errorf("DeliverToTarget(%q, %v) = %v, want %v", tc.externalID, tc.inAppOnly, got, tc.want)
			}
		})
	}
}
