diff --git a/src/__tests__/ChartBuilder.test.tsx b/src/__tests__/ChartBuilder.test.tsx new file mode 100644 index 00000000..11175751 --- /dev/null +++ b/src/__tests__/ChartBuilder.test.tsx @@ -0,0 +1,77 @@ +import React from "react"; +import { render, screen, fireEvent } from "@testing-library/react"; +import ChartBuilder from "@/components/analytics/ChartBuilder"; +import type { ChartBuilderDataPoint } from "@/components/analytics/ChartBuilder"; + +// Mock recharts dynamic imports +jest.mock("next/dynamic", () => () => { + const MockChart = () =>
; + MockChart.displayName = "MockChart"; + return MockChart; +}); + +const makeData = (n = 4): ChartBuilderDataPoint[] => + Array.from({ length: n }, (_, i) => ({ + label: `Week ${i + 1}`, + amount: (i + 1) * 100, + count: i + 1, + successRate: 50 + i * 5, + avgFundingHours: 12 + i, + })); + +describe("ChartBuilder (#798)", () => { + it("renders the section heading", () => { + render(+ {badge.name} +
+ + {badge.tier} + + {!earned && ( + + )} ++ {earned.length} of {BADGE_DEFINITIONS.length} earned +
++ No badges earned yet — keep creating and completing invoices! +
+ )} + + {earned.length > 0 && ( +Earned
+Locked
++ Next up: {locked[0].icon} {locked[0].name} +
+{locked[0].description}
+{amountError}
} ++ Schedule Preview +
++ {FREQUENCY_LABELS[savedConfig?.frequency ?? "one-time"]} · {token} +
+{progressPct}% complete
+{inst.label}
++ Due{" "} + {new Date(inst.dueDate + "T00:00:00").toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + })} +
++ {inst.amount.toLocaleString()} {token} +
+🎉 All instalments paid!
+Browse and import community templates into your library.
++ ⭐ Featured +
+No templates match your search.
+ ) : ( +{t.name}
+{t.description}
+{previewTemplate.description}
+Recipients
++ Showing {data.length} data point{data.length !== 1 ? "s" : ""} · Metric: {METRICS.find((m) => m.value === metric)?.label} +
+