Skip to content

Commit

Permalink
test: add tests for fromQuantityToString
Browse files Browse the repository at this point in the history
  • Loading branch information
jy95 committed Apr 23, 2024
1 parent 1b5a2ab commit 0b676cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __tests__/corner_cases.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("Corner cases", () => {
};

let result = dosageUtils.fromDosageToText(dosage);
expect(result).toBe("42 ");
expect(result).toBe("42");
});

test("rateRatio - no denominator", () => {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/fromQuantityToString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ export function fromQuantityToString({

// Compute the result
let unit = fromFHIRQuantityUnitToString({ language, quantity });
let value = quantity.value || 1;

// If no unit is present (in other words ""), we don't put it
if (unit.length === 0) {
return i18next.t("amount.quantity.withoutUnit", {
quantity: quantity.value,
quantity: value,
});
} else {
return i18next.t("amount.quantity.withUnit", {
quantity: quantity.value,
quantity: value,
unit: unit,
});
}
Expand Down

0 comments on commit 0b676cf

Please sign in to comment.