From e0a0c277964f37d6b32b555cda1c47821141ffe0 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Wed, 3 Apr 2024 09:09:00 -0700 Subject: [PATCH] DurationFormat: added tests for default styles for units following numeric-styled units (#4032) --- .../constructor-unit-style-defaults.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/intl402/DurationFormat/constructor-unit-style-defaults.js diff --git a/test/intl402/DurationFormat/constructor-unit-style-defaults.js b/test/intl402/DurationFormat/constructor-unit-style-defaults.js new file mode 100644 index 0000000000..376220b0fc --- /dev/null +++ b/test/intl402/DurationFormat/constructor-unit-style-defaults.js @@ -0,0 +1,31 @@ +// Copyright 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Verifies that default style settings for units following units with "numeric" or "2-digit" style are honored. +info: | + GetDurationUnitOptions (unit, options, baseStyle, stylesList, digitalBase, prevStyle) + (...) + 3. If style is undefined, then + (...) + i. If prevStyle is "fractional", "numeric" or "2-digit", then + (...) + 2. Set style to "numeric". + (...) + 9. If prevStyle is "numeric" or "2-digit", then + (...) + b. If unit is "minutes" or "seconds", then + i. Set style to "2-digit". +features: [Intl.DurationFormat] +---*/ + +for (const numericLikeStyle of ["numeric", "2-digit"]){ + var opts = new Intl.DurationFormat([], {hours: numericLikeStyle}).resolvedOptions(); + + assert.sameValue(opts.minutes, "2-digit", `minutes default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.seconds, "2-digit", `seconds default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.milliseconds, "numeric", `milliseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.microseconds, "numeric", `microseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.nanoseconds, "numeric", `nanoseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); +}