From 6f664fe9110a3067a0539a0f5eefbadf8d5fd3f2 Mon Sep 17 00:00:00 2001 From: Robert Snow Date: Sat, 2 May 2026 05:47:56 +1000 Subject: [PATCH] fix: calendar tests (#10004) --- packages/react-aria-components/test/Calendar.test.js | 6 ++++-- packages/react-aria-components/test/RangeCalendar.test.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/react-aria-components/test/Calendar.test.js b/packages/react-aria-components/test/Calendar.test.js index 32b61455c68..14fb9193266 100644 --- a/packages/react-aria-components/test/Calendar.test.js +++ b/packages/react-aria-components/test/Calendar.test.js @@ -201,8 +201,10 @@ describe('Calendar', () => { expect(grids).toHaveLength(2); let formatter = new Intl.DateTimeFormat('en-US', {month: 'long', year: 'numeric'}); - expect(grids[0]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(new Date())); - expect(grids[1]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(today(getLocalTimeZone()).add({months: 1}).toDate(getLocalTimeZone()))); + let firstMonth = new CalendarDate(2026, 4, 1); + let tz = getLocalTimeZone(); + expect(grids[0]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(firstMonth.toDate(tz))); + expect(grids[1]).toHaveAttribute('aria-label', 'Appointment date, ' + formatter.format(firstMonth.add({months: 1}).toDate(tz))); let headings = container.querySelectorAll('.react-aria-CalendarHeading'); expect(headings).toHaveLength(2); diff --git a/packages/react-aria-components/test/RangeCalendar.test.tsx b/packages/react-aria-components/test/RangeCalendar.test.tsx index efda39b6d57..73948a1d98d 100644 --- a/packages/react-aria-components/test/RangeCalendar.test.tsx +++ b/packages/react-aria-components/test/RangeCalendar.test.tsx @@ -212,8 +212,10 @@ describe('RangeCalendar', () => { expect(grids).toHaveLength(2); let formatter = new Intl.DateTimeFormat('en-US', {month: 'long', year: 'numeric'}); - expect(grids[0]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(new Date())); - expect(grids[1]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(today(getLocalTimeZone()).add({months: 1}).toDate(getLocalTimeZone()))); + let firstMonth = new CalendarDate(2026, 4, 1); + let tz = getLocalTimeZone(); + expect(grids[0]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(firstMonth.toDate(tz))); + expect(grids[1]).toHaveAttribute('aria-label', 'Trip dates, ' + formatter.format(firstMonth.add({months: 1}).toDate(tz))); let headings = container.querySelectorAll('.react-aria-CalendarHeading'); expect(headings).toHaveLength(2);