1 import { getSmallestUnit } from "../get-smallest-unit"
2
3 describe("getSmallestUnit", () => {
4 it("should convert an amount to the format required by Stripe based on currency", () => {
5 // 0 decimals
6 expect(getSmallestUnit(50098, "JPY")).toBe(50098)
7
8 // 3 decimals
9 expect(getSmallestUnit(5.124, "KWD")).toBe(5130)
10
11 // 2 decimals
12 expect(getSmallestUnit(2.675, "USD")).toBe(268)
13
14 expect(getSmallestUnit(100.54, "USD")).toBe(10054)
15 expect(getSmallestUnit(5.126, "KWD")).toBe(5130)
16 expect(getSmallestUnit(0.54, "USD")).toBe(54)
17 expect(getSmallestUnit(0.054, "USD")).toBe(5)
18 expect(getSmallestUnit(0.005104, "USD")).toBe(1)
19 expect(getSmallestUnit(0.004104, "USD")).toBe(0)
20 })
21 })