package viral

import "testing"

func TestPickDefaultSelectedTags(t *testing.T) {
	tags := []SuggestedTag{
		{Tag: "轉職", SearchType: "短詞"},
		{Tag: "面試焦慮", SearchType: "短詞"},
		{Tag: "被裁怎麼辦", SearchType: "情境"},
		{Tag: "30歲轉職真實心得", SearchType: "情境"},
		{Tag: "努力不一定成功", SearchType: "語錄"},
		{Tag: "@powerfulceo", SearchType: "帳號"},
		{Tag: "薪水談判", SearchType: "短詞"},
	}
	out := PickDefaultSelectedTags(tags)
	if len(out) == 0 {
		t.Fatal("expected selected tags")
	}
	if len(out) > DefaultSelectedTagCount {
		t.Fatalf("expected at most %d tags, got %d", DefaultSelectedTagCount, len(out))
	}
	seen := map[string]struct{}{}
	for _, tag := range out {
		if _, ok := seen[tag]; ok {
			t.Fatalf("duplicate tag %q", tag)
		}
		seen[tag] = struct{}{}
	}
}
