mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:47:35 +00:00
LibJS: Implement Intl.Locale.prototype.timeZones property
This commit is contained in:
parent
fa005bd276
commit
814f13bc2a
6 changed files with 79 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.timeZones;
|
||||
}).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(new Intl.Locale("en").timeZones).toBeUndefined();
|
||||
expect(new Intl.Locale("ar-Latn").timeZones).toBeUndefined();
|
||||
|
||||
const adZones = new Intl.Locale("en-AD").timeZones;
|
||||
expect(Array.isArray(adZones)).toBeTrue();
|
||||
expect(adZones).toEqual(["Europe/Andorra"]);
|
||||
|
||||
const esZones = new Intl.Locale("en-ES").timeZones;
|
||||
expect(Array.isArray(esZones)).toBeTrue();
|
||||
expect(esZones).toEqual(["Africa/Ceuta", "Atlantic/Canary", "Europe/Madrid"]);
|
||||
});
|
||||
|
||||
test("zone list is sorted", () => {
|
||||
const zones = new Intl.Locale("en-US").timeZones;
|
||||
const sortedZones = zones.toSorted();
|
||||
|
||||
expect(zones).toEqual(sortedZones);
|
||||
});
|
||||
|
||||
test("invalid region produces empty list", () => {
|
||||
const zones = new Intl.Locale("en-ZZ").timeZones;
|
||||
expect(Array.isArray(zones)).toBeTrue();
|
||||
expect(zones).toEqual([]);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue