34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { mapMoneyValue, mapQuotationToNumber, mapTimestampToIso } from './money.mapper';
|
|
|
|
describe('money.mapper', () => {
|
|
it('maps positive MoneyValue with nano precision', () => {
|
|
expect(mapMoneyValue({ currency: 'rub', units: '123', nano: 450000000 })).toEqual({
|
|
currency: 'RUB',
|
|
units: '123',
|
|
nano: 450000000,
|
|
value: 123.45,
|
|
});
|
|
});
|
|
|
|
it('maps negative MoneyValue with negative nano', () => {
|
|
expect(mapMoneyValue({ currency: 'rub', units: '-5', nano: -250000000 })).toEqual({
|
|
currency: 'RUB',
|
|
units: '-5',
|
|
nano: -250000000,
|
|
value: -5.25,
|
|
});
|
|
});
|
|
|
|
it('returns null for absent MoneyValue', () => {
|
|
expect(mapMoneyValue(undefined)).toBeNull();
|
|
});
|
|
|
|
it('maps quotation to number', () => {
|
|
expect(mapQuotationToNumber({ units: '12', nano: 345000000 })).toBe(12.345);
|
|
});
|
|
|
|
it('maps unix timestamp seconds to ISO string', () => {
|
|
expect(mapTimestampToIso({ seconds: '1781577000', nanos: 0 })).toBe('2026-06-16T02:30:00.000Z');
|
|
});
|
|
});
|