it("should be applied after conversion to target units", () => {
        var qty = (Qty("2m")).div(3);
        expect(qty.format("cm", roundingFormatter(2))).toBe("66.67 cm");

        var intRoundingFormatter = roundingFormatter(0);
        qty = Qty("2.8m");
        expect(qty.format("m", intRoundingFormatter)).toBe("3 m");
        expect(qty.format("cm", intRoundingFormatter)).toBe("280 cm");
        qty = Qty("2.818m");
        expect(qty.format("cm", intRoundingFormatter)).toBe("282 cm");
      });
        it("should be applied when no formatter is passed", () => {
          var qty = (Qty("2.987654321 m"));

          expect(qty.format()).toBe("2.988 m");
        });
      it("should be applied to output", () => {
        var qty = (Qty("2.987654321 m"));

        expect(qty.format()).toBe("2.987654321 m");
      });
      it("should be applied to output", () => {
        var qty = (Qty("2.987654321 m"));

        expect(qty.format(roundingFormatter(3))).toBe("2.988 m");
        expect(qty.format(roundingFormatter(0))).toBe("3 m");
      });
qty = Qty('1.146 MPa');
qty.toPrec('0.1 bar'); // => 1.15 MPa

qty = Qty('1.146 MPa');
qty.toString(); // => '1.146 MPa'

qty = Qty('1.146 MPa');
qty.toString('bar'); // => '11.46 bar'
qty.to('bar').toString(); // => '11.46 bar'

qty = Qty('1.146 MPa');
qty.toPrec(0.1).toString(); // => '1.1 MPa'
qty.to('bar').toPrec(0.1).toString(); // => '11.5 bar'

qty = Qty('1.1234 m');
qty.format(); // same units, default formatter => '1.234 m'
qty.format('cm'); // converted to 'cm', default formatter => '123.45 cm'

var configurableRoundingFormatter = (maxDecimals: number) => {
  return (scalar: number, units: string) => {
    var pow = Math.pow(10, maxDecimals);
    var rounded = Math.round(scalar * pow) / pow;

    return rounded + ' ' + units;
  };
};

qty = Qty('1.1234 m');

// same units, custom formatter => '1.12 m'
qty.format(configurableRoundingFormatter(2));