it("should be parsed when prefixed", () => { expect(Qty("mAh").eq(Qty("3.6 C"))).toBe(true); });
it("should be cached", () => { const qty = Qty("100 m"), converted = qty.to("ft"); expect(qty.to("ft") === converted).toBe(true); });
it("should be supported as prefix", () => { // µ as greek letter expect(Qty("1 \u03BCm").eq(Qty("1 um"))).toBe(true); // µ as micro sign expect(Qty("1 \u00B5m").eq(Qty("1 um"))).toBe(true); });
it("should allow whitespaces between sign and scalar", () => { const qty = Qty("- 1m"); expect(qty.scalar).toEqual(-1); expect(qty.units()).toEqual("m"); });
it("should return true with dimensionless quantities", () => { const qty1 = Qty("1"); const qty2 = Qty("2"); expect(qty1.isCompatible(qty2)).toBe(true); });
it("should accept empty string as unitless 1", () => { expect(Qty("").same(Qty("1"))).toBe(true); expect(Qty(" ").same(Qty("1"))).toBe(true); });
it("should keep init value as is", () => { const initValue = " 66 cm3 "; const qty = Qty(initValue); expect(qty.initValue).toEqual(initValue); });
it("should create from numbers with explicit units", () => { const qty = Qty(1.5, "m"); expect(qty.scalar).toBe(1.5); expect(qty.numerator).toEqual(["<meter>"]); expect(qty.denominator).toEqual(["<1>"]); });
expect(() => { Qty("-1 tempR"); }).toThrow("Temperatures must not be less than absolute zero");
it("should create unit only", () => { const qty = Qty("m"); expect(qty.numerator).toEqual(["<meter>"]); expect(qty.scalar).toBe(1); });