feat: improve bank card expenses summary
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { type BankSummary, sortBankSummary } from "./queries";
|
||||
|
||||
it("orders displayed expenses descending, preserving cents, ties and source data", () => {
|
||||
const values = [
|
||||
"-10",
|
||||
"9007199254740992.01",
|
||||
"0",
|
||||
"9007199254740992.02",
|
||||
"-2",
|
||||
"0",
|
||||
];
|
||||
const money = (value: string) => ({ currency: "RUB", value });
|
||||
const data: BankSummary = {
|
||||
month: "2026-09",
|
||||
cardId: "a",
|
||||
expenses: money("0"),
|
||||
refunds: money("0"),
|
||||
net: money("0"),
|
||||
categories: values.map((value, index) => ({
|
||||
categoryId: String(index),
|
||||
categoryName: String(index),
|
||||
expenses: money("100"),
|
||||
refunds: money("0"),
|
||||
net: money(value),
|
||||
})),
|
||||
};
|
||||
expect(sortBankSummary(data).categories.map((row) => row.categoryId)).toEqual(
|
||||
["3", "1", "2", "5", "4", "0"],
|
||||
);
|
||||
expect(data.categories.map((row) => row.net.value)).toEqual(values);
|
||||
});
|
||||
Reference in New Issue
Block a user