Skip to content

Commit

Permalink
fix: ratio rendering when no unit is present
Browse files Browse the repository at this point in the history
  • Loading branch information
jy95 committed Apr 20, 2024
1 parent 9ec6260 commit 389327f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __tests__/fromDosageToText/rateRatio.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ describe("fromDosageToText - rateRatio", () => {
};

let result = dosageUtils.fromDosageToText(dosage);
expect(result).toBe("at a rate of 1 :128");
expect(result).toBe("at a rate of 1:128");
});
});
6 changes: 4 additions & 2 deletions src/utils/fromRatioToString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export function fromRatioToString({
let quantityNumerator = numerator?.value;
let quantityDenominator = denominator?.value;

// Collect
// Collect results
const parts: string[] = [];
let noUnits = numeratorUnit === undefined && denominatorUnit === undefined;
let separator = noUnits ? "" : " ";

// Deal with numerator first
if (quantityNumerator !== undefined) {
Expand Down Expand Up @@ -69,6 +71,6 @@ export function fromRatioToString({
if (parts.length === 0) {
return undefined;
} else {
return parts.join(" ");
return parts.join(separator);
}
}

0 comments on commit 389327f

Please sign in to comment.