diff --git a/spec/quantitiesSpec.js b/spec/quantitiesSpec.js index 6ee20da..11065c1 100644 --- a/spec/quantitiesSpec.js +++ b/spec/quantitiesSpec.js @@ -219,13 +219,9 @@ describe("js-quantities", function() { expect(function() { Qty("mmm"); }).toThrow("Unit not recognized"); }); - it("should throw error when passing an empty string", function() { - expect( - function() { Qty(""); } - ).toThrow("Unit not recognized"); - expect( - function() { Qty(" "); } - ).toThrow("Unit not recognized"); + it("should accept empty string as unitless 1", function() { + expect(Qty("").same(Qty("1"))).toBe(true); + expect(Qty(" ").same(Qty("1"))).toBe(true); }); it("should throw error when passing a null value", function() { diff --git a/src/quantities.js b/src/quantities.js index b020386..02ec20a 100644 --- a/src/quantities.js +++ b/src/quantities.js @@ -671,9 +671,6 @@ SOFTWARE. val = val.toString(); } val = val.trim(); - if (val.length === 0) { - throw new QtyError("Unit not recognized"); - } var result = QTY_STRING_REGEX.exec(val); if (!result) {