Improve error failure case handling

This commit is contained in:
Matthias 2023-10-21 17:11:38 +02:00
parent 0f6aec7df8
commit 41f464e4ca
2 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* @returns {stakeCurrency, quoteCurrency}
*/
export function splitTradePair(pair: string): { stakeCurrency: string; quoteCurrency: string } {
if (!pair) return { stakeCurrency: '', quoteCurrency: '' };
const [stakeCurrency, quoteCurrency] = pair.split('/');
const quoteCurrencySplit = quoteCurrency.split(':');
return { stakeCurrency, quoteCurrency: quoteCurrencySplit[0] || quoteCurrency };

View File

@ -23,4 +23,7 @@ describe('splitTradePair', () => {
quoteCurrency: 'USDT',
});
});
it('Does not fail on empty input', () => {
expect(splitTradePair('')).toEqual({ stakeCurrency: '', quoteCurrency: '' });
});
});