import * as utils from './utils'; describe('lookupGrowthStandards', () => { test('It looks up a standard correctly', () => { expect(utils.lookupGrowthStandards([100, 1], ['age', 'sex'], 'acanthro')).toStrictEqual({ age: 100, l: 0.379, m: 13.5836, s: 0.0749, sex: 1, }); }); test('It looks up a length standard with "h" correctly', () => { expect(utils.lookupGrowthStandards([66.1, 1], ['height', 'sex'], 'wfhanthro')).toStrictEqual({ height: 66.1, l: -0.3521, m: 7.6906, s: 0.08212, lorh: 'H', sex: 1, }); }); test('It looks up a length standard with "l" correctly', () => { expect(utils.lookupGrowthStandards([45, 1], ['length', 'sex'], 'wflanthro')).toStrictEqual({ length: 45, l: -0.3521, m: 2.441, s: 0.09182, lorh: 'L', sex: 1, }); }); test('It looks up a length for age standard correctly', () => { expect(utils.lookupGrowthStandards([44, 1], ['age', 'sex'], 'lenanthro')).toStrictEqual({ age: 44, l: 1, m: 56.4833, s: 0.03492, loh: 'L', sex: 1, }); }); test('It looks up a weight for age standard correctly', () => { expect(utils.lookupGrowthStandards([1544, 2], ['age', 'sex'], 'weianthro')).toStrictEqual({ age: 1544, l: -0.3397, m: 16.5639, s: 0.1411, sex: 2, }); }); }); describe('round', () => { test('round to thousandths by default', () => { expect(utils.round(12.3456)).toEqual(12.346); }); test('round to hundredths', () => { expect(utils.round(12.3456, 2)).toEqual(12.35); }); test('round to 6 digits', () => { expect(utils.round(12.345612019831, 6)).toEqual(12.345612); }); });