Skip to content

Commit

Permalink
fix(#2372): fix ada quantities format
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Nov 20, 2024
1 parent c99bc8c commit 72644e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- fix ada quantities format to avoid thousands when the total is 0 [Issue 2372](https://github.com/IntersectMBO/govtool/issues/2382)

### Changed

Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/utils/adaFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export const correctVoteAdaFormat = (
) => {
if (lovelace) {
const ada = lovelace / LOVELACE;

return ada.toLocaleString(locale, {
minimumFractionDigits: 3,
maximumFractionDigits: 3,
});
}
return "0,000";
return "0";
};

export const correctDRepDirectoryFormat = (lovelace: number | undefined) => {
Expand Down
6 changes: 3 additions & 3 deletions govtool/frontend/src/utils/tests/adaFormat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ describe("correctVoteAdaFormat", () => {

test("Returns 0 for undefined lovelace value", () => {
const lovelace = undefined;
const expectedResult = "0,000";
const expectedResult = "0";
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
});

test("Returns 0 for zero lovelace value", () => {
const lovelace = 0;
const expectedResult = "0,000";
const expectedResult = "0";
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
});

test("Returns 0 for small lovelace value", () => {
const lovelace = 123;
const expectedResult = "0.000";
const expectedResult = "0";
expect(correctVoteAdaFormat(lovelace, "en-US")).toBe(expectedResult);
});
});
Expand Down

0 comments on commit 72644e2

Please sign in to comment.