PliWould/lib/__tests__/dimensions-test.ts

15 lines
632 B
TypeScript
Raw Normal View History

import { diameterToLength, length_t } from '../dimensions';
describe('diameterToLength', () => {
it('should throw an error if the units of the outer and inner diameters do not match', () => {
expect(() => diameterToLength({ l: 10, u: 'inch' }, { l: 8, u: 'foot' }, 2)).toThrow('diameter units must match!');
});
it('should return the correct length for multiple rings with different units', () => {
const outer : length_t = {l: 25, u: "in"};
const inner: length_t = {l : 1, u: "in"};
const l = diameterToLength(outer, inner, 12);
expect(l.l).toBeCloseTo(490, -1.0);
});
});