frequi_origin/tests/unit/formatPair.spec.ts

31 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-10-21 15:09:40 +00:00
import { describe, it, expect } from 'vitest';
2024-07-05 12:27:43 +00:00
import { splitTradePair } from '@/utils/formatters/pairFormat';
2023-10-21 15:09:40 +00:00
describe('splitTradePair', () => {
it('Extracts stake and quote currencies from spot pairs', () => {
2023-10-21 15:18:22 +00:00
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' });
2023-10-21 15:09:40 +00:00
});
it('Extracts stake and quote currencies from spot pairs', () => {
expect(splitTradePair('BTC/USDT:USDT')).toEqual({
2023-10-21 15:18:22 +00:00
baseCurrency: 'BTC',
2023-10-21 15:09:40 +00:00
quoteCurrency: 'USDT',
});
2023-10-21 15:18:22 +00:00
expect(splitTradePair('USDT/BTC:BTC')).toEqual({ baseCurrency: 'USDT', quoteCurrency: 'BTC' });
2023-10-21 15:09:40 +00:00
expect(splitTradePair('USDT/USDT:USDT')).toEqual({
2023-10-21 15:18:22 +00:00
baseCurrency: 'USDT',
2023-10-21 15:09:40 +00:00
quoteCurrency: 'USDT',
});
expect(splitTradePair('USDT/USDT:USDT')).toEqual({
2023-10-21 15:18:22 +00:00
baseCurrency: 'USDT',
2023-10-21 15:09:40 +00:00
quoteCurrency: 'USDT',
});
});
2023-10-21 15:11:38 +00:00
it('Does not fail on empty input', () => {
2023-10-21 15:18:22 +00:00
expect(splitTradePair('')).toEqual({ baseCurrency: '', quoteCurrency: '' });
expect(splitTradePair('USDT')).toEqual({ baseCurrency: '', quoteCurrency: 'USDT' });
2023-10-21 15:11:38 +00:00
});
2023-10-21 15:09:40 +00:00
});