refactor: centralize provider projections
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { toSavedCandle } from './tbank-candle.mapper';
|
||||
|
||||
describe('T-Bank candle mapping', () => {
|
||||
it('keeps signed nano precision and requires explicit completeness', () => {
|
||||
const input = { time: { seconds: '1767225600' }, close: { units: '0', nano: -1 } };
|
||||
expect(toSavedCandle(input)).toEqual({
|
||||
time: '2026-01-01T00:00:00.000Z', close: '-0.000000001', isComplete: false,
|
||||
});
|
||||
expect(toSavedCandle({ ...input, isComplete: true }).isComplete).toBe(true);
|
||||
expect(input).toEqual({ time: { seconds: '1767225600' }, close: { units: '0', nano: -1 } });
|
||||
});
|
||||
it.each([
|
||||
{ close: { units: '1' } },
|
||||
{ time: { seconds: 'invalid' }, close: { units: '1' } },
|
||||
{ time: { seconds: '1767225600' } },
|
||||
])('rejects missing or malformed source fields: %j', (input) => {
|
||||
expect(() => toSavedCandle(input)).toThrow('Invalid candle response');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user