From 7b2a9bb441d5bca44906c513be39fa8c26e74fc1 Mon Sep 17 00:00:00 2001 From: Romulo Cintra Date: Thu, 21 Jul 2022 20:07:40 +0200 Subject: [PATCH] DurationFormat basic format tests (#3604) --- .../prototype/format/basic-format-en.js | 26 +++++++++++++ .../prototype/format/style-options-en.js | 37 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/intl402/DurationFormat/prototype/format/basic-format-en.js create mode 100644 test/intl402/DurationFormat/prototype/format/style-options-en.js diff --git a/test/intl402/DurationFormat/prototype/format/basic-format-en.js b/test/intl402/DurationFormat/prototype/format/basic-format-en.js new file mode 100644 index 0000000000..9ff93e42e9 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/basic-format-en.js @@ -0,0 +1,26 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Test if format method formats duration correctly +locale: [en-US] +features: [Intl.DurationFormat] +---*/ + +const duration = { + years: 1, + months: 2, + weeks: 3, + days: 3, + hours: 4, + minutes: 5, + seconds: 6, + milliseconds: 7, + microseconds: 8, + nanoseconds: 9, +}; + +const df = new Intl.DurationFormat('en'); + +assert.sameValue(df.format(duration), "1 year, 2 months, 3 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds, 8 microseconds, and 9 nanoseconds"); diff --git a/test/intl402/DurationFormat/prototype/format/style-options-en.js b/test/intl402/DurationFormat/prototype/format/style-options-en.js new file mode 100644 index 0000000000..6428f64aa5 --- /dev/null +++ b/test/intl402/DurationFormat/prototype/format/style-options-en.js @@ -0,0 +1,37 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Test if format method formats duration correctly with different "style" arguments +locale: [en-US] +features: [Intl.DurationFormat] +---*/ + +const testData = { + "long" : "1 year, 2 months, 3 weeks, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds, 8 microseconds, and 9 nanoseconds", + "short": "1 yr, 2 mths, 3 wks, 3 days, 4 hr, 5 min, 6 sec, 7 ms, 8 μs, and 9 ns", + "narrow":"1y, 2m, 3w, 3d, 4h, 5m, 6s, 7ms, 8μs, and 9ns", + "digital":"1y, 2m, 3w, 3d, and 4:05:06.007", +} + +const duration = { + years: 1, + months: 2, + weeks: 3, + days: 3, + hours: 4, + minutes: 5, + seconds: 6, + milliseconds: 7, + microseconds: 8, + nanoseconds: 9, +}; + + +for (const style in testData) { + const df = new Intl.DurationFormat("en", {style}); + const expected = testData[style]; + assert.sameValue(df.format(duration), expected, `Assert DurationFormat format output using ${style} style option`); +} +