LibJS: Separate validation of roundingIncrement option

This is an editorial change in the temporal spec.

See: 712c449
This commit is contained in:
forchane 2024-03-20 13:08:47 -05:00 committed by Tim Flynn
commit d2e4da62c8
Notes: sideshowbarker 2024-07-17 09:48:50 +09:00
6 changed files with 125 additions and 58 deletions

View file

@ -122,5 +122,23 @@ describe("errors", () => {
expect(() => {
plainTime.round({ smallestUnit: "second", roundingIncrement: Infinity });
}).toThrowWithMessage(RangeError, "inf is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "hours", roundingIncrement: 24 });
}).toThrowWithMessage(RangeError, "24 is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "minutes", roundingIncrement: 60 });
}).toThrowWithMessage(RangeError, "60 is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "seconds", roundingIncrement: 60 });
}).toThrowWithMessage(RangeError, "60 is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "milliseconds", roundingIncrement: 1000 });
}).toThrowWithMessage(RangeError, "1000 is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "microseconds", roundingIncrement: 1000 });
}).toThrowWithMessage(RangeError, "1000 is not a valid value for option roundingIncrement");
expect(() => {
plainTime.round({ smallestUnit: "nanoseconds", roundingIncrement: 1000 });
}).toThrowWithMessage(RangeError, "1000 is not a valid value for option roundingIncrement");
});
});