This commit was merged in pull request #84.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import type {
|
||||
TbankBond,
|
||||
TbankShare,
|
||||
} from '../../../../integrations/tbank/tbank.api';
|
||||
|
||||
import { publicInstrument } from './public-instrument';
|
||||
|
||||
const share = {
|
||||
uid: 'share-uid',
|
||||
figi: 'FIGI1',
|
||||
assetUid: 'asset-1',
|
||||
name: 'Share',
|
||||
ticker: 'SHAR',
|
||||
isin: 'US000',
|
||||
classCode: 'TQBR',
|
||||
realExchange: 'REAL_EXCHANGE_MOEX',
|
||||
apiTradeAvailableFlag: true,
|
||||
currency: 'rub',
|
||||
shareType: 'SHARE_TYPE_COMMON',
|
||||
sector: 'Finance',
|
||||
lot: 1,
|
||||
brand: { logoName: 'logo.png', title: 'Brand', id: 'brand-1' },
|
||||
first_1dayCandleDate: '2020-01-01T00:00:00Z',
|
||||
privateField: 'must-not-leak',
|
||||
} as unknown as TbankShare;
|
||||
|
||||
const bond = {
|
||||
uid: 'bond-uid',
|
||||
figi: 'FIGI2',
|
||||
assetUid: 'asset-2',
|
||||
name: 'Bond',
|
||||
ticker: 'BOND',
|
||||
classCode: 'TQOB',
|
||||
currency: 'rub',
|
||||
lot: 1,
|
||||
nominal: { value: '1000', currency: 'rub' },
|
||||
initialNominal: { value: '1000', currency: 'rub' },
|
||||
aciValue: { value: '10', currency: 'rub' },
|
||||
maturityDate: '2030-01-01T00:00:00Z',
|
||||
couponQuantityPerYear: 2,
|
||||
bondType: 'BOND_TYPE_EXPIRING',
|
||||
brand: null,
|
||||
privateField: 'must-not-leak',
|
||||
} as unknown as TbankBond;
|
||||
|
||||
describe('publicInstrument projection', () => {
|
||||
it('keeps approved share fields, trims brand, drops private extras', () => {
|
||||
const result = publicInstrument(share);
|
||||
expect(result.uid).toBe('share-uid');
|
||||
expect(result.shareType).toBe('SHARE_TYPE_COMMON');
|
||||
expect(result.brand).toEqual({ logoName: 'logo.png' });
|
||||
expect(result).not.toHaveProperty('privateField');
|
||||
expect(result).not.toHaveProperty('brand.title');
|
||||
});
|
||||
|
||||
it('projects bonds with missing optional fields and null brand', () => {
|
||||
const result = publicInstrument(bond);
|
||||
expect(result.nominal).toEqual({ value: '1000', currency: 'rub' });
|
||||
expect(result.shareType).toBeUndefined();
|
||||
expect(result.brand).toBeUndefined();
|
||||
expect(result.isin).toBeUndefined();
|
||||
expect(result).not.toHaveProperty('privateField');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user