From 886c7d352933acad01ca3751663307a355afecb8 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 11 Aug 2026 18:48:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customers/overseasStorageFeeTiers.test.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/modules/customers/overseasStorageFeeTiers.test.ts b/src/modules/customers/overseasStorageFeeTiers.test.ts index 253fba5b..cdbe9235 100644 --- a/src/modules/customers/overseasStorageFeeTiers.test.ts +++ b/src/modules/customers/overseasStorageFeeTiers.test.ts @@ -8,21 +8,30 @@ function tier(id: string, feeType: OverseasFeeType, startDay: number, endDay: nu describe('overseas storage fee tier editing', () => { it('adds a new open-ended tier and closes the previous tail', () => { - const tiers = [tier('s1', 'STORAGE', 1, null), tier('r1', 'RETURN_STORAGE', 1, null)] + const tiers = [ + tier('s1', 'STORAGE', 1, 7), tier('s2', 'STORAGE', 8, 30), tier('s3', 'STORAGE', 31, 60), + tier('s4', 'STORAGE', 61, 90), tier('s5', 'STORAGE', 91, null), + tier('r1', 'RETURN_STORAGE', 1, null), + ] expect(addFeeTier(tiers, 'STORAGE')).toBeNull() - expect(tiers.filter((item) => item.feeType === 'STORAGE').map(({ startDay, endDay }) => ({ startDay, endDay }))) - .toEqual([{ startDay: 1, endDay: 1 }, { startDay: 2, endDay: null }]) + const storageTiers = tiers.filter((item) => item.feeType === 'STORAGE') + expect(storageTiers).toHaveLength(6) + expect(storageTiers.slice(-2).map(({ startDay, endDay }) => ({ startDay, endDay }))) + .toEqual([{ startDay: 91, endDay: 91 }, { startDay: 92, endDay: null }]) expect(validateFeeTiers(tiers)).toBeNull() }) it('removes a middle tier and extends the previous range', () => { const tiers = [ - tier('s1', 'STORAGE', 1, 7), tier('s2', 'STORAGE', 8, 30), tier('s3', 'STORAGE', 31, null), + tier('s1', 'STORAGE', 1, 7), tier('s2', 'STORAGE', 8, 30), tier('s3', 'STORAGE', 31, 60), + tier('s4', 'STORAGE', 61, 90), tier('s5', 'STORAGE', 91, null), tier('r1', 'RETURN_STORAGE', 1, null), ] - expect(removeFeeTier(tiers, tiers[1]!)).toBeNull() - expect(tiers.slice(0, 2).map(({ startDay, endDay }) => ({ startDay, endDay }))) - .toEqual([{ startDay: 1, endDay: 30 }, { startDay: 31, endDay: null }]) + expect(removeFeeTier(tiers, tiers[2]!)).toBeNull() + const storageTiers = tiers.filter((item) => item.feeType === 'STORAGE') + expect(storageTiers).toHaveLength(4) + expect(storageTiers.slice(1, 3).map(({ startDay, endDay }) => ({ startDay, endDay }))) + .toEqual([{ startDay: 8, endDay: 60 }, { startDay: 61, endDay: 90 }]) expect(validateFeeTiers(tiers)).toBeNull() })