first commit

This commit is contained in:
2026-07-16 20:48:43 -03:00
commit 5696cee264
1111 changed files with 322270 additions and 0 deletions
@@ -0,0 +1,43 @@
import dayjs from "dayjs";
describe("PlanSubscriptions Logic", () => {
it("should calculate correct endDate for 1, 3, 6, 12 months", () => {
const start = dayjs("2024-01-01T10:00:00.000Z");
const end1 = start.clone().add(1, "months");
expect(end1.format("YYYY-MM-DD")).toBe("2024-02-01");
const end3 = start.clone().add(3, "months");
expect(end3.format("YYYY-MM-DD")).toBe("2024-04-01");
const end6 = start.clone().add(6, "months");
expect(end6.format("YYYY-MM-DD")).toBe("2024-07-01");
const end12 = start.clone().add(12, "months");
expect(end12.format("YYYY-MM-DD")).toBe("2025-01-01");
});
it("should calculate total price correctly with discounts", () => {
const planPrice = 1000;
// 1 month, 0 discount
const total1 = planPrice * 1;
const final1 = total1 - (total1 * (0 / 100));
expect(final1).toBe(1000);
// 3 months, 10% discount
const total3 = planPrice * 3; // 3000
const final3 = total3 - (total3 * (10 / 100)); // 3000 - 300 = 2700
expect(final3).toBe(2700);
// 6 months, 20% discount
const total6 = planPrice * 6; // 6000
const final6 = total6 - (total6 * (20 / 100)); // 6000 - 1200 = 4800
expect(final6).toBe(4800);
// 12 months, 30% discount
const total12 = planPrice * 12; // 12000
const final12 = total12 - (total12 * (30 / 100)); // 12000 - 3600 = 8400
expect(final12).toBe(8400);
});
});