summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Intl/DisplayNames/abbreviated.js
blob: 4203ffcbac151b072f4a94a1ca27e625a6b0d5fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// |reftest| skip-if(!this.hasOwnProperty('Intl')||!this.hasOwnProperty('addIntlExtras'))

addMozIntlDisplayNames(this);

const tests = {
  "en": {
    long: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
    abbreviated: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    short: ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
    narrow: ["M", "T", "W", "T", "F", "S", "S"],
  },
};

for (let [locale, localeTests] of Object.entries(tests)) {
  for (let [style, weekdays] of Object.entries(localeTests)) {
    let dn = new Intl.DisplayNames(locale, {type: "weekday", style});

    let resolved = dn.resolvedOptions();
    assertEq(resolved.style, style);

    for (let [day, expected] of weekdays.entries()) {
      assertEq(dn.of(day + 1), expected);
    }
  }
}

if (typeof reportCompare === "function")
  reportCompare(true, true);