LEARN_ENGLISH plans unlock LMS only; IELTS and DUOLINGO unlock matching exam-prep catalog courses. Enable category subscription gating, restrict programs to Learn English, and treat Duolingo subscriptions as non-expiring one-time purchases. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package domain
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCalculateSubscriptionExpiresAt_duolingoIsLifetime(t *testing.T) {
|
|
start := time.Date(2026, 6, 10, 12, 0, 0, 0, time.UTC)
|
|
got := CalculateSubscriptionExpiresAt(start, "DUOLINGO", 1, "MONTH")
|
|
if !got.Equal(LifetimeSubscriptionExpiresAt) {
|
|
t.Fatalf("expected lifetime expiry, got %v", got)
|
|
}
|
|
}
|
|
|
|
func TestSubscriptionGrantsContentAccess(t *testing.T) {
|
|
if !SubscriptionGrantsContentAccess("LEARN_ENGLISH", "LEARN_ENGLISH") {
|
|
t.Fatal("LEARN_ENGLISH plan should unlock LMS content")
|
|
}
|
|
if SubscriptionGrantsContentAccess("LEARN_ENGLISH", "IELTS") {
|
|
t.Fatal("LEARN_ENGLISH plan should not unlock exam prep content")
|
|
}
|
|
if !SubscriptionGrantsContentAccess("IELTS", "IELTS") {
|
|
t.Fatal("IELTS plan should unlock IELTS content")
|
|
}
|
|
if SubscriptionGrantsContentAccess("IELTS", "DUOLINGO") {
|
|
t.Fatal("IELTS plan should not unlock Duolingo content")
|
|
}
|
|
if !SubscriptionGrantsContentAccess("DUOLINGO", "DUOLINGO") {
|
|
t.Fatal("DUOLINGO plan should unlock Duolingo content")
|
|
}
|
|
}
|
|
|
|
func TestCalculateSubscriptionExpiresAt_learnEnglishUsesDuration(t *testing.T) {
|
|
start := time.Date(2026, 6, 10, 12, 0, 0, 0, time.UTC)
|
|
got := CalculateSubscriptionExpiresAt(start, "LEARN_ENGLISH", 1, "MONTH")
|
|
want := start.AddDate(0, 1, 0)
|
|
if !got.Equal(want) {
|
|
t.Fatalf("expected %v, got %v", want, got)
|
|
}
|
|
}
|