Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should divide while trying to avoid numerical errors", () => {
expect(Qty.divSafe(0.000773, 0.000001)).toBe(773);
// TODO uncomment and fix
// expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2);
});
});
it("should divide while trying to avoid numerical errors", () => {
expect(Qty.divSafe(0.000773, 0.000001)).toBe(773);
// TODO uncomment and fix
// expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2);
});
});
it("should convert to compatible units", () => {
let qty = Qty("10 cm");
expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048));
qty = Qty("2m^3");
expect(qty.to("l").scalar).toBe(2000);
qty = Qty("10 cm");
expect(qty.to(Qty("m")).scalar).toBe(0.1);
expect(qty.to(Qty("20m")).scalar).toBe(0.1);
qty = Qty("1 m3");
expect(qty.to("cm3").scalar).toBe(1000000);
qty = Qty("1 cm3");
expect(qty.to("mm3").scalar).toBe(1000);
qty = Qty("550 cm3");
expect(qty.to("cm^3").scalar).toBe(550);
it("should convert to compatible units", () => {
let qty = Qty("10 cm");
expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048));
qty = Qty("2m^3");
expect(qty.to("l").scalar).toBe(2000);
qty = Qty("10 cm");
expect(qty.to(Qty("m")).scalar).toBe(0.1);
expect(qty.to(Qty("20m")).scalar).toBe(0.1);
qty = Qty("1 m3");
expect(qty.to("cm3").scalar).toBe(1000000);
qty = Qty("1 cm3");
expect(qty.to("mm3").scalar).toBe(1000);
qty = Qty("550 cm3");
expect(qty.to("cm^3").scalar).toBe(550);