mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 02:11:57 +00:00
Improve error failure case handling
This commit is contained in:
parent
0f6aec7df8
commit
41f464e4ca
|
@ -4,6 +4,7 @@
|
||||||
* @returns {stakeCurrency, quoteCurrency}
|
* @returns {stakeCurrency, quoteCurrency}
|
||||||
*/
|
*/
|
||||||
export function splitTradePair(pair: string): { stakeCurrency: string; quoteCurrency: string } {
|
export function splitTradePair(pair: string): { stakeCurrency: string; quoteCurrency: string } {
|
||||||
|
if (!pair) return { stakeCurrency: '', quoteCurrency: '' };
|
||||||
const [stakeCurrency, quoteCurrency] = pair.split('/');
|
const [stakeCurrency, quoteCurrency] = pair.split('/');
|
||||||
const quoteCurrencySplit = quoteCurrency.split(':');
|
const quoteCurrencySplit = quoteCurrency.split(':');
|
||||||
return { stakeCurrency, quoteCurrency: quoteCurrencySplit[0] || quoteCurrency };
|
return { stakeCurrency, quoteCurrency: quoteCurrencySplit[0] || quoteCurrency };
|
||||||
|
|
|
@ -23,4 +23,7 @@ describe('splitTradePair', () => {
|
||||||
quoteCurrency: 'USDT',
|
quoteCurrency: 'USDT',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('Does not fail on empty input', () => {
|
||||||
|
expect(splitTradePair('')).toEqual({ stakeCurrency: '', quoteCurrency: '' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user