Files
go-onlyoffice/crm_normalize_test.go
T
eSliderandCursor a59b4fb296 feat(crm): merge company slogan variants in dedupe grouping
Treat names like "Affirm" and "Affirm — Fraud Engineering" as the same
company for dedupe, deal matching, members, and applications sync lookup.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 12:40:27 +01:00

105 lines
2.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package onlyoffice
import "testing"
func TestNormalizeCompanyName(t *testing.T) {
tests := []struct {
in, want string
}{
{" contoso ", "contoso"},
{"Contoso", "contoso"},
{"Acme Corp", "acme corp"},
}
for _, tc := range tests {
if got := NormalizeCompanyName(tc.in); got != tc.want {
t.Errorf("NormalizeCompanyName(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestNormalizePersonKey(t *testing.T) {
if got := NormalizePersonKey(" Jane ", " Doe "); got != "jane doe" {
t.Fatalf("got %q", got)
}
}
func TestFixDealTitle(t *testing.T) {
tests := []struct {
in, want string
}{
{" @ contoso", "contoso"},
{"@ contoso", "contoso"},
{"@Acme", "Acme"},
{"Dev@Acme", "Dev @ Acme"},
{"Dev @ Acme", "Dev @ Acme"},
{"Senior Dev @ Acme", "Senior Dev @ Acme"},
{"", ""},
}
for _, tc := range tests {
if got := FixDealTitle(tc.in); got != tc.want {
t.Errorf("FixDealTitle(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestStripSloganSuffix(t *testing.T) {
tests := []struct {
in, want string
}{
{"Affirm — Fraud Engineering", "Affirm"},
{"Affirm - Fraud Engineering", "Affirm"},
{"Affirm – Fraud Engineering", "Affirm"},
{"Affirm", "Affirm"},
{"— leading", "— leading"},
}
for _, tc := range tests {
if got := StripSloganSuffix(tc.in); got != tc.want {
t.Errorf("StripSloganSuffix(%q) = %q, want %q", tc.in, got, tc.want)
}
}
}
func TestCompanyGroupingKey(t *testing.T) {
a := CompanyGroupingKey("Affirm")
b := CompanyGroupingKey("Affirm — Fraud Engineering")
if a != b {
t.Fatalf("%q != %q", a, b)
}
}
func TestOpportunityTitlesMatchSlogan(t *testing.T) {
if !OpportunityTitlesMatch("Dev @ Affirm — Fraud Engineering", "Dev @ Affirm") {
t.Fatal("expected match")
}
}
func TestStripCompanySuffix(t *testing.T) {
if got := StripCompanySuffix("Dev @ Acme"); got != "Dev" {
t.Fatalf("got %q", got)
}
if got := StripCompanySuffix("Dev"); got != "Dev" {
t.Fatalf("got %q", got)
}
}
func TestContactInfoKey(t *testing.T) {
if got := ContactInfoKey("Email", " A@B.COM "); got != "email|a@b.com" {
t.Fatalf("got %q", got)
}
}
func TestMemberDisplayKey(t *testing.T) {
if got := MemberDisplayKey(" contoso "); got != "contoso" {
t.Fatalf("got %q", got)
}
}
func TestDealTitleForApplication(t *testing.T) {
if got := DealTitleForApplication("", "contoso"); got != "contoso" {
t.Fatalf("got %q", got)
}
if got := DealTitleForApplication("Dev", "Acme"); got != "Dev @ Acme" {
t.Fatalf("got %q", got)
}
}