Add currency settings, Settings service, and dialog to select fiat currency. Add support for non Official currencies like DOGE when using rates.
This commit is contained in:
40
tests/cli/rates-format.test.ts
Normal file
40
tests/cli/rates-format.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/// <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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user