@@ -7,6 +7,8 @@ import {
|
||||
calcOrderBoxCount,
|
||||
shouldHoldAutoCourierDispatch,
|
||||
validateMinPurchase,
|
||||
toBottleQuantity,
|
||||
toMinSaleQuantity,
|
||||
validateBusinessHours,
|
||||
formatBusinessHours,
|
||||
validateRedeemAmount,
|
||||
@@ -47,6 +49,30 @@ describe('validateMinPurchase', () => {
|
||||
expect(validateMinPurchase('ON_SITE_PICKUP', 1, 2, 6).ok).toBe(false);
|
||||
expect(validateMinPurchase('ON_SITE_PICKUP', 2, 2, 6).ok).toBe(true);
|
||||
});
|
||||
|
||||
it('box SKU: 1 box (6 bottles) satisfies local and cross mins', () => {
|
||||
const opts = { bottlesPerUnit: 6, saleUnit: 'BOX' as const };
|
||||
expect(validateMinPurchase('LOCAL', 1, 2, 6, opts).ok).toBe(true);
|
||||
expect(validateMinPurchase('CROSS_CITY', 1, 2, 6, opts).ok).toBe(true);
|
||||
expect(validateMinPurchase('ON_SITE_PICKUP', 1, 2, 6, opts).ok).toBe(true);
|
||||
});
|
||||
|
||||
it('box SKU message uses 箱', () => {
|
||||
const r = validateMinPurchase('LOCAL', 0, 2, 6, { bottlesPerUnit: 6, saleUnit: 'BOX' });
|
||||
expect(r.ok).toBe(false);
|
||||
expect(r.message).toContain('箱');
|
||||
});
|
||||
});
|
||||
|
||||
describe('toBottleQuantity / toMinSaleQuantity', () => {
|
||||
it('converts sale qty to bottles', () => {
|
||||
expect(toBottleQuantity(2, 1)).toBe(2);
|
||||
expect(toBottleQuantity(1, 6)).toBe(6);
|
||||
expect(toMinSaleQuantity(2, 1)).toBe(2);
|
||||
expect(toMinSaleQuantity(2, 6)).toBe(1);
|
||||
expect(toMinSaleQuantity(6, 6)).toBe(1);
|
||||
expect(toMinSaleQuantity(7, 6)).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateBusinessHours', () => {
|
||||
|
||||
Reference in New Issue
Block a user