plan-templates.test.js
2.12 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
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'
})
})
})
describe('critical illness mpc special age options', () => {
it('should expose pregnancy week option only for mpc', () => {
expect(PLAN_TEMPLATES['critical-illness-mpc'].config.special_age_options).toEqual(['孕22周'])
expect(PLAN_TEMPLATES['critical-illness-mbc-pro'].config.special_age_options).toBeUndefined()
expect(PLAN_TEMPLATES['critical-illness-mbc2'].config.special_age_options).toBeUndefined()
})
})
describe('savings gs multistage payment periods', () => {
it('should include 2-year payment period option', () => {
expect(PLAN_TEMPLATES['savings-gs-multistage'].config.payment_periods).toContain('2 年')
})
})