mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-17 15:20:58 +00:00
Paper trading system with 5 commands (trade_topup, trade_buy, trade_sell, trade_convert, trade_stats). Supports VN stocks via TCBS, crypto via CoinGecko, forex via ER-API, and gold via PAX Gold proxy. Per-user portfolio stored in KV with 60s price caching. 54 new tests.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
CURRENCIES,
|
|
SYMBOLS,
|
|
getSymbol,
|
|
listSymbols,
|
|
} from "../../../src/modules/trading/symbols.js";
|
|
|
|
describe("trading/symbols", () => {
|
|
it("SYMBOLS has 9 entries across 3 categories", () => {
|
|
expect(Object.keys(SYMBOLS)).toHaveLength(9);
|
|
const cats = new Set(Object.values(SYMBOLS).map((s) => s.category));
|
|
expect(cats).toEqual(new Set(["crypto", "stock", "others"]));
|
|
});
|
|
|
|
it("getSymbol is case-insensitive", () => {
|
|
const btc = getSymbol("btc");
|
|
expect(btc).toBeDefined();
|
|
expect(btc.symbol).toBe("BTC");
|
|
expect(btc.category).toBe("crypto");
|
|
|
|
expect(getSymbol("Tcb").symbol).toBe("TCB");
|
|
});
|
|
|
|
it("getSymbol returns undefined for unknown symbols", () => {
|
|
expect(getSymbol("NOPE")).toBeUndefined();
|
|
expect(getSymbol("")).toBeUndefined();
|
|
expect(getSymbol(null)).toBeUndefined();
|
|
});
|
|
|
|
it("CURRENCIES contains VND and USD", () => {
|
|
expect(CURRENCIES.has("VND")).toBe(true);
|
|
expect(CURRENCIES.has("USD")).toBe(true);
|
|
expect(CURRENCIES.has("EUR")).toBe(false);
|
|
});
|
|
|
|
it("listSymbols returns grouped output", () => {
|
|
const out = listSymbols();
|
|
expect(out).toContain("Crypto:");
|
|
expect(out).toContain("BTC — Bitcoin");
|
|
expect(out).toContain("Stocks:");
|
|
expect(out).toContain("TCB — Techcombank");
|
|
expect(out).toContain("Others:");
|
|
expect(out).toContain("GOLD — Gold");
|
|
});
|
|
});
|