Skip to content
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
33 changes: 22 additions & 11 deletions tests/govtool-frontend/playwright/lib/helpers/adaFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,26 @@ export const correctDRepDirectoryFormat = (ada: number | undefined) => {
return "0";
};

export const formatWithThousandSeparator = (
amount: number | undefined,
isAda: boolean = true
) => {
const updatedAmount = !isAda ? Math.ceil(amount / LOVELACE) : amount;
if (updatedAmount) {
return updatedAmount.toLocaleString("en-us", {
maximumFractionDigits: 3,
});
export function formatWithThousandSeparator(
value: number | string,
isAda = true
): string {
if (value === undefined || value === null) {
return "0";
}
return "0";
};

let numericValue: number;
if (typeof value === "string") {
numericValue = parseInt(value.replace(/,/g, ""));
} else {
numericValue = value;
}

if (!isAda) {
numericValue = Math.ceil(numericValue / LOVELACE);
}

return numericValue.toLocaleString("en-US", {
maximumFractionDigits: 3,
});
}
6 changes: 6 additions & 0 deletions tests/govtool-frontend/playwright/lib/helpers/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ export function toCamelCase(str: string) {
)
.join("");
}

export function generateParagraph(isValid: boolean, isEmpty: boolean): string {
if (isValid) return faker.lorem.paragraph(2);
const text = isEmpty ? "" : faker.lorem.paragraph(15001);
return text;
}
Loading