import { describe, expect, it } from 'vitest'; import { matchCategoryLabelToCode } from '../src/services/orderParseService'; describe('matchCategoryLabelToCode', () => { const names = new Map([ ['CAT_DRY', '干杂'], ['CAT_VEG', '蔬菜'], ]); it('matches by code or exact name', () => { expect(matchCategoryLabelToCode('CAT_DRY', names)).toBe('CAT_DRY'); expect(matchCategoryLabelToCode('干杂', names)).toBe('CAT_DRY'); expect(matchCategoryLabelToCode('蔬菜(CAT_VEG)', names)).toBe('CAT_VEG'); }); it('returns null for invented names', () => { expect(matchCategoryLabelToCode('冻品', names)).toBeNull(); expect(matchCategoryLabelToCode('', names)).toBeNull(); }); });