mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
LibJS: Populate roundingPriority in Intl.PluralRules.resolvedOptions
This is inherited from Intl.NumberFormat.
This commit is contained in:
parent
33698b9615
commit
cd4ee46b70
3 changed files with 47 additions and 1 deletions
|
@ -116,6 +116,15 @@ describe("errors", () => {
|
|||
new Intl.PluralRules("en", { maximumSignificantDigits: 22 });
|
||||
}).toThrowWithMessage(RangeError, "Value 22 is NaN or is not between 1 and 21");
|
||||
});
|
||||
|
||||
test("roundingPriority option is invalid", () => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingPriority: "hello!" });
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"hello! is not a valid value for option roundingPriority"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
|
@ -178,4 +187,12 @@ describe("normal behavior", () => {
|
|||
}).not.toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
test("all valid roundingPriority options", () => {
|
||||
["auto", "morePrecision", "lessPrecision"].forEach(roundingPriority => {
|
||||
expect(() => {
|
||||
new Intl.PluralRules("en", { roundingPriority: roundingPriority });
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -104,4 +104,14 @@ describe("correct behavior", () => {
|
|||
expect(gaOrdinal.pluralCategories).toBeDefined();
|
||||
expect(contains(gaOrdinal.pluralCategories, ["other", "one"])).toBeTrue();
|
||||
});
|
||||
|
||||
test("rounding priority", () => {
|
||||
const en1 = new Intl.PluralRules("en");
|
||||
expect(en1.resolvedOptions().roundingPriority).toBe("auto");
|
||||
|
||||
["auto", "morePrecision", "lessPrecision"].forEach(roundingPriority => {
|
||||
const en2 = new Intl.PluralRules("en", { roundingPriority: roundingPriority });
|
||||
expect(en2.resolvedOptions().roundingPriority).toBe(roundingPriority);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue