-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathaccount.test.ts
More file actions
91 lines (88 loc) · 2.26 KB
/
Copy pathaccount.test.ts
File metadata and controls
91 lines (88 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { AltynAccount } from '../../../models'
import { convertAccounts } from '../../../converters'
describe('convertAccounts', () => {
it('should convert ruble account', () => {
const accounts: AltynAccount[] = [
{
account_number: 'A-100000000001',
bank_name: null,
bic: null,
bank_inn: null,
bank_kpp: null,
cor_account: null,
currency: 'RUB',
balance: '12345.67'
}
]
expect(convertAccounts(accounts)).toEqual([
{
account: {
id: 'A-100000000001',
type: 'checking',
title: 'Алтын A-100000000001',
instrument: 'RUB',
balance: 12345.67,
syncIds: ['A-100000000001']
},
accountNumber: 'A-100000000001'
}
])
})
it('should convert account with integer balance', () => {
const accounts: AltynAccount[] = [
{
account_number: 'A-200000000002',
bank_name: null,
bic: null,
bank_inn: null,
bank_kpp: null,
cor_account: null,
currency: 'USD',
balance: '0'
}
]
expect(convertAccounts(accounts)).toEqual([
{
account: {
id: 'A-200000000002',
type: 'checking',
title: 'Алтын A-200000000002',
instrument: 'USD',
balance: 0,
syncIds: ['A-200000000002']
},
accountNumber: 'A-200000000002'
}
])
})
it('should convert multiple accounts', () => {
const accounts: AltynAccount[] = [
{
account_number: 'A-300000000003',
bank_name: null,
bic: null,
bank_inn: null,
bank_kpp: null,
cor_account: null,
currency: 'RUB',
balance: '100.50'
},
{
account_number: 'A-400000000004',
bank_name: null,
bic: null,
bank_inn: null,
bank_kpp: null,
cor_account: null,
currency: 'EUR',
balance: '200'
}
]
const result = convertAccounts(accounts)
expect(result).toHaveLength(2)
expect(result[0].account.instrument).toBe('RUB')
expect(result[1].account.instrument).toBe('EUR')
expect(result[0].account.balance).toBe(100.50)
expect(result[1].account.balance).toBe(200)
})
})