Files
admin-web/src/modules/overseas-warehouse/relabelRework.test.ts
T
2026-10-09 17:27:47 +08:00

19 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { reworkRelabelApplications } from './relabelRework'
describe('tail-order relabel rework candidates', () => {
it('uses each return relabel application instead of the aggregate completed status', () => {
const applications = [
{ relabelNo: 'RL-1', status: 'CUSTOMER_CONFIRM_PENDING', quantity: 1, createdAt: '', statusLabel: '' },
{ relabelNo: 'RL-2', status: 'COMPLETED', quantity: 1, createdAt: '', statusLabel: '' },
{ relabelNo: 'RL-3', status: 'PROCESSING', quantity: 1, createdAt: '', statusLabel: '' },
]
expect(reworkRelabelApplications({ relabelOrderNo: '', relabelApplications: applications, relabelStatusCode: 'COMPLETED' }).map(item => item.relabelNo)).toEqual(['RL-1', 'RL-3'])
})
it('preserves the existing single-application entry and excludes confirmed orders', () => {
expect(reworkRelabelApplications({ relabelOrderNo: 'RL-1', relabelStatusCode: 'CUSTOMER_CONFIRM_PENDING' })).toHaveLength(1)
expect(reworkRelabelApplications({ relabelOrderNo: 'RL-1', relabelStatusCode: 'READY_FOR_OUTBOUND' })).toEqual([])
expect(reworkRelabelApplications({ relabelOrderNo: '', relabelStatusCode: 'PROCESSING' })).toEqual([])
})
})