mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 21:31:59 +03:00
Add missing edge case tests for resolveZone
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
bede889ced
commit
0961af12f0
1 changed files with 21 additions and 0 deletions
|
|
@ -58,6 +58,27 @@ describe("datetime", () => {
|
||||||
expect(resolveZone(["london"])).toBe("Europe/London");
|
expect(resolveZone(["london"])).toBe("Europe/London");
|
||||||
expect(resolveZone(["tokyo"])).toBe("Asia/Tokyo");
|
expect(resolveZone(["tokyo"])).toBe("Asia/Tokyo");
|
||||||
expect(resolveZone(["buenos", "aires"])).toBe("America/Argentina/Buenos_Aires");
|
expect(resolveZone(["buenos", "aires"])).toBe("America/Argentina/Buenos_Aires");
|
||||||
|
expect(resolveZone(["ho", "chi", "minh"])).toBe("Asia/Ho_Chi_Minh");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should resolve longest prefix when trailing words are present", () => {
|
||||||
|
expect(resolveZone(["new", "york", "city"])).toBe("America/New_York");
|
||||||
|
expect(resolveZone(["utc", "time"])).toBe("UTC");
|
||||||
|
expect(resolveZone(["london", "england"])).toBe("Europe/London");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle 'local' even with extra words", () => {
|
||||||
|
const mockResolvedOptions = vi.fn().mockReturnValue({ timeZone: "America/Los_Angeles" });
|
||||||
|
const mockDateTimeFormat = vi.spyOn(Intl, "DateTimeFormat").mockImplementation(() => ({
|
||||||
|
resolvedOptions: mockResolvedOptions,
|
||||||
|
}) as any);
|
||||||
|
|
||||||
|
expect(resolveZone(["local", "time"])).toBe("America/Los_Angeles");
|
||||||
|
mockDateTimeFormat.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should handle empty arrays gracefully", () => {
|
||||||
|
expect(resolveZone([])).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should resolve russian cities", () => {
|
it("should resolve russian cities", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue