42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { buildPossibleDuplicateGroups } from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/utils/possibleDuplicateGroups.js";
|
|
|
|
const customer = (customerNumber, customerName, transactions) => ({
|
|
customer_number: customerNumber,
|
|
customer_name: customerName,
|
|
requires_action: true,
|
|
transactions,
|
|
});
|
|
|
|
const transaction = (id, reg_1, created_at) => ({
|
|
id,
|
|
reg_1,
|
|
created_at,
|
|
amount: 100,
|
|
booked: false,
|
|
excluded: false,
|
|
});
|
|
|
|
describe("possible duplicate groups", () => {
|
|
it("excludes groups with only one active wash log by default", () => {
|
|
const groups = buildPossibleDuplicateGroups([
|
|
customer(1001, "First Customer", [transaction(1, "EC 21233", "2026-05-11 10:00:00")]),
|
|
customer(1002, "Second Customer", [transaction(2, "EC21233", "2026-05-11 11:00:00")]),
|
|
customer(1003, "Single Customer", [transaction(3, "SINGLE1", "2026-05-11 12:00:00")]),
|
|
]);
|
|
|
|
expect(groups.map((group) => group.key)).toEqual(["EC21233|2026-05-11"]);
|
|
expect(groups[0].transactions).toHaveLength(2);
|
|
});
|
|
|
|
it("can include singletons explicitly for callers that need raw grouping", () => {
|
|
const groups = buildPossibleDuplicateGroups(
|
|
[customer(1003, "Single Customer", [transaction(3, "SINGLE1", "2026-05-11 12:00:00")])],
|
|
{ includeSingletons: true }
|
|
);
|
|
|
|
expect(groups.map((group) => group.key)).toEqual(["SINGLE1|2026-05-11"]);
|
|
});
|
|
});
|