import assert from "node:assert/strict";
import test from "node:test";
import { calculateCnyAmount, currencyMinorUnits } from "./index.js";

test("currency metadata uses zero minor units for JPY", () => {
  assert.equal(currencyMinorUnits("JPY"), 0);
  assert.equal(currencyMinorUnits("THB"), 2);
});

test("currency conversion rounds to the nearest CNY fen", () => {
  assert.equal(calculateCnyAmount(12345, "THB", "0.201010000000"), 2481);
  assert.equal(calculateCnyAmount(2500, "USD", "6.773000000000"), 16933);
  assert.equal(calculateCnyAmount(1234, "JPY", "0.0473"), 5837);
});
