frequi_origin/tests/unit/formatPair.spec.ts
2024-07-05 14:27:43 +02:00

31 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { splitTradePair } from '@/utils/formatters/pairFormat';
describe('splitTradePair', () => {
it('Extracts stake and quote currencies from spot pairs', () => {
expect(splitTradePair('BTC/USDT')).toEqual({ baseCurrency: 'BTC', quoteCurrency: 'USDT' });
expect(splitTradePair('USDT/BTC')).toEqual({ baseCurrency: 'USDT', quoteCurrency: 'BTC' });
expect(splitTradePair('USDT/USDT')).toEqual({ baseCurrency: 'USDT', quoteCurrency: 'USDT' });
expect(splitTradePair('USDT/USDT')).toEqual({ baseCurrency: 'USDT', quoteCurrency: 'USDT' });
});
it('Extracts stake and quote currencies from spot pairs', () => {
expect(splitTradePair('BTC/USDT:USDT')).toEqual({
baseCurrency: 'BTC',
quoteCurrency: 'USDT',
});
expect(splitTradePair('USDT/BTC:BTC')).toEqual({ baseCurrency: 'USDT', quoteCurrency: 'BTC' });
expect(splitTradePair('USDT/USDT:USDT')).toEqual({
baseCurrency: 'USDT',
quoteCurrency: 'USDT',
});
expect(splitTradePair('USDT/USDT:USDT')).toEqual({
baseCurrency: 'USDT',
quoteCurrency: 'USDT',
});
});
it('Does not fail on empty input', () => {
expect(splitTradePair('')).toEqual({ baseCurrency: '', quoteCurrency: '' });
expect(splitTradePair('USDT')).toEqual({ baseCurrency: '', quoteCurrency: 'USDT' });
});
});