Skip to content

Commit

Permalink
Fix toMaxAllowedDecimalsNumberString
Browse files Browse the repository at this point in the history
  • Loading branch information
gpxl-dev committed Sep 4, 2023
1 parent 8a9bd6d commit 99c9138
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
13 changes: 2 additions & 11 deletions src/helpers/toMaxAllowedDecimalsNumberString.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ describe("toMaxAllowedDecimalsNumberString", () => {
it("should not round number string when it has less decimals than the max allowed", () => {
const result1 = toMaxAllowedDecimalsNumberString("0.0004", 6);
const result2 = toMaxAllowedDecimalsNumberString(".00004", 6);
const result3 = toMaxAllowedDecimalsNumberString("1.343434344334", 6);

expect(result1).toBe("0.0004");
expect(result2).toBe(".00004");
});

it("should not try to round numbers bigger than 1", () => {
const result1 = toMaxAllowedDecimalsNumberString("1.343434344334", 6);
const result2 = toMaxAllowedDecimalsNumberString(
"999999999999999999.9999999999999",
6
);

expect(result1).toBe("1.343434344334");
expect(result2).toBe("999999999999999999.9999999999999");
expect(result3).toBe("1.343434");
});
});
4 changes: 0 additions & 4 deletions src/helpers/toMaxAllowedDecimalsNumberString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ const toMaxAllowedDecimalsNumberString = (
);
const firstCharacterIsPeriod = firstCharacter === ".";

if (firstCharacterIsNonZero) {
return value;
}

if (
value === "" ||
value === "." ||
Expand Down

0 comments on commit 99c9138

Please sign in to comment.