adding tests for new attach flows

This commit is contained in:
John Yeo
2025-06-04 07:24:05 +01:00
parent 72c06f594d
commit 5b5af8638e
11 changed files with 35 additions and 17 deletions

View File

@@ -55,6 +55,10 @@ export const getSingularAndPlural = ({
};
};
export const numberWithCommas = (x: number) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
export const getFeatureInvoiceDescription = ({
feature,
usage,
@@ -66,11 +70,12 @@ export const getFeatureInvoiceDescription = ({
}) => {
const { singular, plural } = getSingularAndPlural({ feature });
const usageStr = numberWithCommas(usage);
if (billingUnits == 1) {
if (usage == 1)
return `${usage} ${singular}`; // eg. 1 credit
else return `${usage} ${plural}`; // eg. 4 credits
return `${usageStr} ${singular}`; // eg. 1 credit
else return `${usageStr} ${plural}`; // eg. 4 credits
} else {
return `${usage} x ${billingUnits} ${plural}`; // eg. 4 x 100 credits
return `${usageStr} x ${billingUnits} ${plural}`; // eg. 4 x 100 credits
}
};