18 lines
651 B
TypeScript
18 lines
651 B
TypeScript
import { describe, it, expect } from "vitest";
|
||
import { formatMoney, formatPhone, digitsOnly } from "./format";
|
||
|
||
describe("format", () => {
|
||
it("formatMoney groups thousands and adds ₽", () => {
|
||
expect(formatMoney(1000)).toBe("1 000 ₽");
|
||
expect(formatMoney(-3200)).toBe("−3 200 ₽");
|
||
expect(formatMoney(0)).toBe("0 ₽");
|
||
});
|
||
it("digitsOnly strips non-digits", () => {
|
||
expect(digitsOnly("+7 (914) 305-44-00")).toBe("79143054400");
|
||
});
|
||
it("formatPhone renders +7 mask progressively", () => {
|
||
expect(formatPhone("9143054400")).toBe("+7 914 305-44-00");
|
||
expect(formatPhone("914305")).toBe("+7 914 305");
|
||
});
|
||
});
|