refactor: split currency and key/metal formatting into separate units

this simplifies functions and tests, and will make currency optional/variable later
This commit is contained in:
xenticore
2025-04-16 14:04:39 -04:00
parent cb07930c6d
commit dcf45c2740
5 changed files with 51 additions and 19 deletions

View File

@@ -0,0 +1,17 @@
import { describe, expect, test, jest, mock, beforeEach } from "bun:test";
import { convertTF2PriceToUSD } from '../src/content/utils/currency'
mock.module('../src/content/config', () => ({
conversion_ref_usd: 0.05 // Mock conversion rate
}))
describe('Currency Service', () => {
beforeEach(() => {
jest.clearAllMocks()
});
test('convertTF2PriceToUSD returns correct price', () => {
expect(convertTF2PriceToUSD(1, 10, 50)).toBe(3);
})
})