plan-templates.test.js
1.49 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
import { describe, expect, it } from 'vitest'
import { PLAN_TEMPLATES } from '../plan-templates'
import { PLAN_FIELD_DEFINITIONS } from '../plan-fields'
describe('plan template amount field mapping', () => {
it('should map protection coverage to coverage api field', () => {
expect(PLAN_TEMPLATES['life-insurance-wiop3e'].config.submit_mapping.coverage).toEqual({
api_field: 'coverage',
transform: 'fen_to_yuan'
})
})
it('should use annual_premium field for savings schema and submit mapping', () => {
const savingsConfig = PLAN_TEMPLATES['savings-gs'].config
const annualPremiumField = savingsConfig.form_schema.base_fields.find(field => field.key === 'annual_premium')
expect(annualPremiumField).toMatchObject({
key: 'annual_premium',
label: '年缴保费',
type: 'amount'
})
expect(savingsConfig.submit_mapping.annual_premium).toEqual({
api_field: 'annual_premium',
transform: 'fen_to_yuan'
})
expect(savingsConfig.submit_mapping.coverage).toBeUndefined()
})
})
describe('plan field definitions amount semantics', () => {
it('should expose separate coverage and annual_premium definitions', () => {
expect(PLAN_FIELD_DEFINITIONS.coverage).toMatchObject({
label: '保额',
api_field: 'coverage',
transform: 'fen_to_yuan'
})
expect(PLAN_FIELD_DEFINITIONS.annual_premium).toMatchObject({
label: '年缴保费',
api_field: 'annual_premium',
transform: 'fen_to_yuan'
})
})
})