Files
descrybe/apps/api/internal/billing/stripe_sales_quote_test.go
T
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

47 lines
1.1 KiB
Go

package billing
import (
"testing"
"time"
)
func TestSalesQuoteCancelAt(t *testing.T) {
now := time.Date(2026, 8, 8, 12, 0, 0, 0, time.UTC)
got, err := salesQuoteCancelAt(now, 4, "month")
if err != nil {
t.Fatal(err)
}
want := time.Date(2026, 12, 8, 12, 0, 0, 0, time.UTC)
if !got.Equal(want) {
t.Fatalf("month cancel_at = %v, want %v", got, want)
}
got, err = salesQuoteCancelAt(now, 2, "quarter")
if err != nil {
t.Fatal(err)
}
want = time.Date(2027, 2, 8, 12, 0, 0, 0, time.UTC)
if !got.Equal(want) {
t.Fatalf("quarter cancel_at = %v, want %v", got, want)
}
got, err = salesQuoteCancelAt(now, 1, "year")
if err != nil {
t.Fatal(err)
}
want = time.Date(2027, 8, 8, 12, 0, 0, 0, time.UTC)
if !got.Equal(want) {
t.Fatalf("year cancel_at = %v, want %v", got, want)
}
}
func TestStripeRecurringFromInstallment(t *testing.T) {
iv, n, err := stripeRecurringFromInstallment("quarter")
if err != nil || iv != "month" || n != 3 {
t.Fatalf("quarter => %s/%d err=%v", iv, n, err)
}
iv, n, err = stripeRecurringFromInstallment("month")
if err != nil || iv != "month" || n != 1 {
t.Fatalf("month => %s/%d err=%v", iv, n, err)
}
}