You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.1 KiB

import { lookupCurrency } from '@ghostfolio/api/helper/market-currencies.helper';
describe('lookupCurrency', () => {
it('should return null if param is empty or null', () => {
expect(lookupCurrency(null)).toBeNull();
expect(lookupCurrency('')).toBeNull();
expect(lookupCurrency(' ')).toBeNull();
});
it('should return corresponding market currency from suffix code', () => {
expect(lookupCurrency('VN')).toStrictEqual('VND');
expect(lookupCurrency('T')).toStrictEqual('JPY');
});
});
describe('determineStockCurrency', () => {
it('should return corresponding market currency from symbol has suffix code', () => {
expect(lookupCurrency('MBB.VN')).toStrictEqual('VND');
expect(lookupCurrency('7203.T')).toStrictEqual('JPY');
expect(lookupCurrency('EA.BK')).toStrictEqual('THB');
});
it('should return null if symbol has no suffix code', () => {
expect(lookupCurrency('APPL')).toBeNull();
expect(lookupCurrency('TLSA')).toBeNull();
});
it('should return null if symbol has suffix code but not supported in json data', () => {
expect(lookupCurrency('A.CBT')).toBeNull();
});
});