41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
/// <reference types="node" />
|
|
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
import { BaseRates } from "../../src/utils/rates/base-rates";
|
|
|
|
/**
|
|
* Minimal concrete adapter used only for testing BaseRates helpers.
|
|
*/
|
|
class TestRatesAdapter extends BaseRates {
|
|
public async start(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
public async stop(): Promise<void> {
|
|
return;
|
|
}
|
|
|
|
public async listPairs(): Promise<Set<string>> {
|
|
return new Set(["USD/BCH", "DOGE/BCH"]);
|
|
}
|
|
}
|
|
|
|
describe("BaseRates.formatCurrency", () => {
|
|
test("formats ISO currency codes with Intl currency style", () => {
|
|
const rates = new TestRatesAdapter();
|
|
const formatted = rates.formatCurrency(12.5, "USD");
|
|
|
|
expect(formatted).toContain("$");
|
|
expect(formatted).toContain("12.50");
|
|
});
|
|
|
|
test("formats non-ISO symbols without throwing", () => {
|
|
const rates = new TestRatesAdapter();
|
|
const formatted = rates.formatCurrency(12.3456789, "DOGE");
|
|
|
|
expect(formatted).toContain("DOGE");
|
|
expect(formatted).toContain("12.3456789");
|
|
});
|
|
});
|