Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#2372): fix ada quantities format #2396

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ changes.

- Fix listing voted-on governance actions [Issue 2379](https://github.com/IntersectMBO/govtool/issues/2379)
- Fix wronly displayed markdown on slider card [Issue 2263](https://github.com/IntersectMBO/govtool/issues/2316)
- 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
Loading