import { expect, it } from "vitest"; import { type BankSummary, sortBankSummary } from "./queries"; const money = (value: string) => ({ currency: "RUB", value }); it("orders displayed expenses descending, preserving cents, ties and source data", () => { const values = [ "-10", "9007199254740992.01", "0", "9007199254740992.02", "-2", "0", ]; const data: BankSummary = { cardId: "a", categories: values.map((value, index) => ({ categoryId: String(index), categoryName: String(index), expenses: money("100"), net: money(value), refunds: money("0"), })), expenses: money("0"), month: "2026-09", net: money("0"), refunds: money("0"), }; 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); });