54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package learnernotifications
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"Rezina-Backend/internal/domain"
|
|
)
|
|
|
|
func TestSubscriptionPackageLabel(t *testing.T) {
|
|
if got := subscriptionPackageLabel("IELTS"); got != "IELTS" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
if got := subscriptionPackageLabel("learn_english"); got != "Learn English" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestSubscriptionExpiresLabel(t *testing.T) {
|
|
expiresAt := time.Date(2026, 12, 31, 0, 0, 0, 0, time.UTC)
|
|
|
|
label, lifetime := subscriptionExpiresLabel(domain.LifetimeSubscriptionExpiresAt)
|
|
if !lifetime || label != "" {
|
|
t.Fatalf("lifetime label=%q lifetime=%v", label, lifetime)
|
|
}
|
|
|
|
label, lifetime = subscriptionExpiresLabel(expiresAt)
|
|
if lifetime || label != "Dec 31, 2026" {
|
|
t.Fatalf("dated label=%q lifetime=%v", label, lifetime)
|
|
}
|
|
}
|
|
|
|
func TestSubscriptionActivatedMessage(t *testing.T) {
|
|
msg := subscriptionActivatedMessage(string(domain.SubscriptionCategoryIELTS), "Premium")
|
|
if msg == "" || msg == "Premium" {
|
|
t.Fatalf("unexpected message: %q", msg)
|
|
}
|
|
}
|
|
|
|
func TestMakeupArtistrySubscriptionMessages(t *testing.T) {
|
|
if label := subscriptionPackageLabel(" education "); label != "Makeup Artistry" {
|
|
t.Fatalf("label=%q", label)
|
|
}
|
|
message := subscriptionActivatedMessage("EDUCATION", "Bridal Academy Pass")
|
|
if !strings.Contains(message, "Bridal Academy Pass") || !strings.Contains(message, "makeup artistry") || strings.Contains(message, "English") {
|
|
t.Fatalf("unexpected makeup message: %q", message)
|
|
}
|
|
// Historical subscriptions retain their original labels and behavior.
|
|
if label := subscriptionPackageLabel("LEARN_ENGLISH"); label != "Learn English" {
|
|
t.Fatalf("legacy label=%q", label)
|
|
}
|
|
}
|