71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import {
|
|
accessibleTbankAccount,
|
|
supportedTbankAccounts,
|
|
} from './tbank-account-policy';
|
|
|
|
describe('tbank-account-policy', () => {
|
|
it('normalizes supported account types and fallback names', () => {
|
|
expect(
|
|
supportedTbankAccounts([
|
|
{
|
|
id: 'brokerage',
|
|
type: 'ACCOUNT_TYPE_TINKOFF',
|
|
name: ' Основной ',
|
|
openedDate: { seconds: '1723507200' },
|
|
},
|
|
{ id: 'debit', type: 'ACCOUNT_TYPE_DEBIT', name: 'Дебетовый' },
|
|
{ id: 'iis', type: 'ACCOUNT_TYPE_TINKOFF_IIS', name: ' ' },
|
|
{ id: 'box', type: 'ACCOUNT_TYPE_INVEST_BOX', name: ' ' },
|
|
{ id: 'fund', type: 'ACCOUNT_TYPE_INVEST_FUND', name: ' ' },
|
|
]),
|
|
).toEqual([
|
|
{
|
|
id: 'brokerage',
|
|
type: 'BROKERAGE',
|
|
name: 'Основной',
|
|
openedOn: '2024-08-13',
|
|
},
|
|
{
|
|
id: 'iis',
|
|
type: 'INDIVIDUAL_INVESTMENT',
|
|
name: 'ИИС',
|
|
openedOn: null,
|
|
},
|
|
{
|
|
id: 'box',
|
|
type: 'INVEST_BOX',
|
|
name: 'Инвесткопилка',
|
|
openedOn: null,
|
|
},
|
|
{
|
|
id: 'fund',
|
|
type: 'MONEY_MARKET_FUND',
|
|
name: 'Фонд денежного рынка',
|
|
openedOn: null,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it('matches account-scoped access only for supported account types', () => {
|
|
expect(
|
|
accessibleTbankAccount(
|
|
[
|
|
{ id: 'account', type: 'ACCOUNT_TYPE_DEBIT', name: 'Debit' },
|
|
{ id: 'other', type: 'ACCOUNT_TYPE_TINKOFF', name: 'Other' },
|
|
],
|
|
'account',
|
|
),
|
|
).toBeNull();
|
|
expect(
|
|
accessibleTbankAccount(
|
|
[{ id: 'account', type: 'ACCOUNT_TYPE_TINKOFF', name: 'Brokerage' }],
|
|
'account',
|
|
),
|
|
).toEqual({
|
|
id: 'account',
|
|
type: 'ACCOUNT_TYPE_TINKOFF',
|
|
name: 'Brokerage',
|
|
});
|
|
});
|
|
});
|