Skip to content

Commit 6f664fe

Browse files
authored
fix: calendar tests (#10004)
1 parent 1b4438c commit 6f664fe

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/react-aria-components/test/Calendar.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ describe('Calendar', () => {
201201
expect(grids).toHaveLength(2);
202202

203203
let formatter = new Intl.DateTimeFormat('en-US', {month: 'long', year: 'numeric'});
204-
expect(grids[0]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(new Date()));
205-
expect(grids[1]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(today(getLocalTimeZone()).add({months: 1}).toDate(getLocalTimeZone())));
204+
let firstMonth = new CalendarDate(2026, 4, 1);
205+
let tz = getLocalTimeZone();
206+
expect(grids[0]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(firstMonth.toDate(tz)));
207+
expect(grids[1]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(firstMonth.add({months: 1}).toDate(tz)));
206208

207209
let headings = container.querySelectorAll('.react-aria-CalendarHeading');
208210
expect(headings).toHaveLength(2);

packages/react-aria-components/test/RangeCalendar.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ describe('RangeCalendar', () => {
212212
expect(grids).toHaveLength(2);
213213

214214
let formatter = new Intl.DateTimeFormat('en-US', {month: 'long', year: 'numeric'});
215-
expect(grids[0]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(new Date()));
216-
expect(grids[1]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(today(getLocalTimeZone()).add({months: 1}).toDate(getLocalTimeZone())));
215+
let firstMonth = new CalendarDate(2026, 4, 1);
216+
let tz = getLocalTimeZone();
217+
expect(grids[0]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(firstMonth.toDate(tz)));
218+
expect(grids[1]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(firstMonth.add({months: 1}).toDate(tz)));
217219

218220
let headings = container.querySelectorAll('.react-aria-CalendarHeading');
219221
expect(headings).toHaveLength(2);

0 commit comments

Comments
 (0)