this repo has no description
1import { findDstTransitions, DstTransitions } from './tzCommon';
2
3// Generated for year 2025 by generateExpectedTransitions.ts
4const expectedTransitions: { zone: string; expected: DstTransitions }[] = [
5 {
6 zone: 'America/New_York',
7 expected: [-18000, -14400, 1741503600, 1762063200] as DstTransitions,
8 },
9 {
10 zone: 'Europe/London',
11 expected: [0, 3600, 1743296400, 1761440400] as DstTransitions,
12 },
13 {
14 zone: 'Pacific/Auckland',
15 expected: [43200, 46800, 1758981600, 1743861600] as DstTransitions,
16 },
17 {
18 zone: 'Asia/Tokyo',
19 expected: [32400, 32400, 0, 0] as DstTransitions,
20 },
21 {
22 zone: 'Pacific/Apia',
23 // Note: Expected output shows Apia has no DST in 2025 according to Luxon/IANA data used.
24 expected: [46800, 46800, 0, 0] as DstTransitions,
25 },
26 {
27 zone: 'Australia/Lord_Howe',
28 expected: [37800, 39600, 1759593600, 1743865200] as DstTransitions,
29 },
30 {
31 zone: 'America/Denver',
32 expected: [-25200, -21600, 1741510800, 1762070400] as DstTransitions,
33 },
34 {
35 zone: 'Asia/Katmandu',
36 expected: [20700, 20700, 0, 0] as DstTransitions,
37 },
38 {
39 zone: 'Invalid/Zone',
40 expected: [0, 0, 0, 0] as DstTransitions,
41 },
42];
43
44describe('tzCommon', () => {
45 describe('findDstTransitions', () => {
46 const year = 2025; // Match the year used for generation
47
48 test.each(expectedTransitions)('should match generated expected value for $zone in $year', ({ zone, expected }) => {
49 const result = findDstTransitions(zone, year);
50
51 // Explicitly compare each element
52 expect(result[0]).toBe(expected[0]); // stdOffsetSeconds
53 expect(result[1]).toBe(expected[1]); // dstOffsetSeconds
54 expect(result[2]).toBe(expected[2]); // dstStartUtcTimestamp
55 expect(result[3]).toBe(expected[3]); // dstEndUtcTimestamp
56 });
57
58 // Keep cache test as it verifies TS internal behavior
59 test('should use cache for repeated calls', () => {
60 const zone = 'America/Los_Angeles';
61 const year = 2026; // Use a different year
62
63 const result1 = findDstTransitions(zone, year);
64 const result2 = findDstTransitions(zone, year);
65 expect(result1).toEqual(result2);
66 });
67 });
68});