|
|
@@ -6,6 +6,8 @@ import {
|
|
|
formatReceiveAccountLine,
|
|
|
isReceiveAccountSnapshot,
|
|
|
normalizeReceiveAccountModelValue,
|
|
|
+ optionLabelFromRow,
|
|
|
+ snapshotFromRow,
|
|
|
type ReceiveAccountSnapshot
|
|
|
} from './oa-receive-account-value'
|
|
|
|
|
|
@@ -65,4 +67,70 @@ describe('oa-receive-account-value', () => {
|
|
|
const text = formatReceiveAccountDisplay([alipay, personal])
|
|
|
assert.ok(text.includes('\n'))
|
|
|
})
|
|
|
+ it('format line personal province only', () => {
|
|
|
+ const line = formatReceiveAccountLine({
|
|
|
+ ...personal,
|
|
|
+ bankCity: ''
|
|
|
+ })
|
|
|
+ assert.ok(line.includes('安徽省'))
|
|
|
+ assert.ok(!line.includes(' / '))
|
|
|
+ })
|
|
|
+ it('format line personal city only', () => {
|
|
|
+ const line = formatReceiveAccountLine({
|
|
|
+ ...personal,
|
|
|
+ bankProvince: ''
|
|
|
+ })
|
|
|
+ assert.ok(line.includes('合肥市'))
|
|
|
+ assert.ok(!line.includes(' / '))
|
|
|
+ })
|
|
|
+ it('optionLabelFromRow minimal row', () => {
|
|
|
+ assert.equal(
|
|
|
+ optionLabelFromRow({
|
|
|
+ accountType: 'alipay',
|
|
|
+ accountName: '张三',
|
|
|
+ accountNo: '13800138000'
|
|
|
+ }),
|
|
|
+ '支付宝 · 张三 · 13800138000'
|
|
|
+ )
|
|
|
+ })
|
|
|
+ it('optionLabelFromRow unknown type falls back to raw type', () => {
|
|
|
+ assert.equal(
|
|
|
+ optionLabelFromRow({
|
|
|
+ accountType: 'other',
|
|
|
+ accountName: '王五',
|
|
|
+ accountNo: '9999'
|
|
|
+ }),
|
|
|
+ 'other · 王五 · 9999'
|
|
|
+ )
|
|
|
+ })
|
|
|
+ it('snapshotFromRow maps and trims fields', () => {
|
|
|
+ assert.deepEqual(
|
|
|
+ snapshotFromRow({
|
|
|
+ id: ' 10 ',
|
|
|
+ accountType: 'corporate',
|
|
|
+ accountName: ' 公司 ',
|
|
|
+ accountNo: ' 123 ',
|
|
|
+ bankName: '建行',
|
|
|
+ bankProvince: '北京',
|
|
|
+ bankCity: '北京',
|
|
|
+ bankBranch: '分行',
|
|
|
+ remark: '备注'
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ id: '10',
|
|
|
+ accountType: 'corporate',
|
|
|
+ accountName: '公司',
|
|
|
+ accountNo: '123',
|
|
|
+ bankName: '建行',
|
|
|
+ bankProvince: '北京',
|
|
|
+ bankCity: '北京',
|
|
|
+ bankBranch: '分行',
|
|
|
+ remark: '备注'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+ it('snapshotFromRow defaults invalid type to personal', () => {
|
|
|
+ const snap = snapshotFromRow({ id: '1', accountType: 'invalid' })
|
|
|
+ assert.equal(snap.accountType, 'personal')
|
|
|
+ })
|
|
|
})
|