import { describe, expect, it } from 'vitest'; import { assertPositiveSupplyCostPrice, isPositiveSupplyCostPrice, } from '../src/services/supplyCostPrice'; describe('supplyCostPrice', () => { it('accepts prices greater than 0', () => { expect(isPositiveSupplyCostPrice(0.01)).toBe(true); expect(assertPositiveSupplyCostPrice(1.5, '实采单价')).toBe(1.5); }); it('rejects zero and negative', () => { expect(isPositiveSupplyCostPrice(0)).toBe(false); expect(isPositiveSupplyCostPrice(-1)).toBe(false); expect(isPositiveSupplyCostPrice('')).toBe(false); expect(isPositiveSupplyCostPrice(null)).toBe(false); expect(() => assertPositiveSupplyCostPrice(0, '实采单价')).toThrow(/必须大于 0/); expect(() => assertPositiveSupplyCostPrice(-0.1, '采购价')).toThrow(/必须大于 0/); }); });