feat(driver-pwa): pure money/phone/amount helpers + tests
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { keypadReduce, withCommission } from "./amount";
|
||||
|
||||
describe("amount keypad", () => {
|
||||
it("appends digits, ignores leading zero, caps length", () => {
|
||||
expect(keypadReduce("0", "5")).toBe("5");
|
||||
expect(keypadReduce("100", "0")).toBe("1000");
|
||||
expect(keypadReduce("", "0")).toBe("");
|
||||
expect(keypadReduce("999999", "9")).toBe("999999");
|
||||
});
|
||||
it("backspace removes last digit", () => {
|
||||
expect(keypadReduce("105", "back")).toBe("10");
|
||||
expect(keypadReduce("", "back")).toBe("");
|
||||
});
|
||||
it("withCommission computes total at given rate", () => {
|
||||
expect(withCommission(1000, 0.052)).toEqual({ commission: 52, total: 1052 });
|
||||
expect(withCommission(333, 0.052)).toEqual({ commission: 17.32, total: 350.32 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user