import { getDimensionBounds, getWeightBounds } from '../shared/utils/unitBounds'; // ------------------------------------------------------------------------- describe( 'getDimensionBounds', () => { // Positive it( 'returns min=1 and max=150 for cm', () => { const bounds = getDimensionBounds( 'cm' ); expect( bounds.min ).toBe( 1 ); expect( bounds.max ).toBe( 150 ); } ); it( 'step equals min', () => { const bounds = getDimensionBounds( 'cm' ); expect( bounds.step ).toBe( bounds.min ); } ); it( 'converts correctly for mm (1cm = 10mm)', () => { const bounds = getDimensionBounds( 'mm' ); expect( bounds.min ).toBeCloseTo( 10 ); expect( bounds.max ).toBeCloseTo( 1500 ); } ); it( 'converts correctly for inches (1cm = 1/2.54 in)', () => { const bounds = getDimensionBounds( 'in' ); expect( bounds.min ).toBeCloseTo( 1 / 2.54, 4 ); expect( bounds.max ).toBeCloseTo( 150 / 2.54, 2 ); } ); it( 'converts correctly for metres (1cm = 0.01m)', () => { const bounds = getDimensionBounds( 'm' ); expect( bounds.min ).toBeCloseTo( 0.01 ); expect( bounds.max ).toBeCloseTo( 1.5 ); } ); // Negative it( 'falls back to cm factor for unknown unit', () => { const bounds = getDimensionBounds( 'furlongs' ); expect( bounds.min ).toBe( 1 ); expect( bounds.max ).toBe( 150 ); } ); } ); // ------------------------------------------------------------------------- describe( 'getWeightBounds', () => { // Positive it( 'returns min≈0.01 for kg', () => { const bounds = getWeightBounds( 'kg' ); expect( bounds.min ).toBeCloseTo( 0.01 ); expect( bounds.step ).toBeCloseTo( 0.01 ); } ); it( 'converts correctly for grams (0.01kg = 10g)', () => { const bounds = getWeightBounds( 'g' ); expect( bounds.min ).toBeCloseTo( 10 ); } ); it( 'converts correctly for lbs', () => { const bounds = getWeightBounds( 'lbs' ); expect( bounds.min ).toBeCloseTo( 0.01 / 0.45359237, 4 ); } ); it( 'converts correctly for oz', () => { const bounds = getWeightBounds( 'oz' ); expect( bounds.min ).toBeCloseTo( 0.01 / 0.028349523125, 2 ); } ); // Negative it( 'falls back to kg factor for unknown unit', () => { const bounds = getWeightBounds( 'stones' ); expect( bounds.min ).toBeCloseTo( 0.01 ); } ); } );