diff --git a/packages/circuit-ui/components/DateInput/DateInput.spec.tsx b/packages/circuit-ui/components/DateInput/DateInput.spec.tsx
index e9522a3595..0d25229f73 100644
--- a/packages/circuit-ui/components/DateInput/DateInput.spec.tsx
+++ b/packages/circuit-ui/components/DateInput/DateInput.spec.tsx
@@ -182,32 +182,38 @@ describe('DateInput', () => {
);
});
- it.skip('should mark the year input as readonly when the minimum and maximum dates have the same year', () => {
- render();
- expect(screen.getByLabelText(/year/i)).toHaveAttribute('readonly');
- expect(screen.getByLabelText(/month/i)).toHaveAttribute(
- 'aria-valuemin',
- '4',
- );
- expect(screen.getByLabelText(/month/i)).toHaveAttribute(
- 'aria-valuemax',
- '6',
- );
- });
+ it.todo(
+ 'should mark the year input as readonly when the minimum and maximum dates have the same year',
+ () => {
+ render();
+ expect(screen.getByLabelText(/year/i)).toHaveAttribute('readonly');
+ expect(screen.getByLabelText(/month/i)).toHaveAttribute(
+ 'aria-valuemin',
+ '4',
+ );
+ expect(screen.getByLabelText(/month/i)).toHaveAttribute(
+ 'aria-valuemax',
+ '6',
+ );
+ },
+ );
- it.skip('should mark the year and month inputs as readonly when the minimum and maximum dates have the same year and month', () => {
- render();
- expect(screen.getByLabelText(/year/i)).toHaveAttribute('readonly');
- expect(screen.getByLabelText(/month/i)).toHaveAttribute('readonly');
- expect(screen.getByLabelText(/day/i)).toHaveAttribute(
- 'aria-valuemin',
- '9',
- );
- expect(screen.getByLabelText(/day/i)).toHaveAttribute(
- 'aria-valuemax',
- '27',
- );
- });
+ it.todo(
+ 'should mark the year and month inputs as readonly when the minimum and maximum dates have the same year and month',
+ () => {
+ render();
+ expect(screen.getByLabelText(/year/i)).toHaveAttribute('readonly');
+ expect(screen.getByLabelText(/month/i)).toHaveAttribute('readonly');
+ expect(screen.getByLabelText(/day/i)).toHaveAttribute(
+ 'aria-valuemin',
+ '9',
+ );
+ expect(screen.getByLabelText(/day/i)).toHaveAttribute(
+ 'aria-valuemax',
+ '27',
+ );
+ },
+ );
});
describe('state', () => {
diff --git a/packages/circuit-ui/components/DateInput/DateInputService.spec.ts b/packages/circuit-ui/components/DateInput/DateInputService.spec.ts
index 0d22581ce9..baeaed93fd 100644
--- a/packages/circuit-ui/components/DateInput/DateInputService.spec.ts
+++ b/packages/circuit-ui/components/DateInput/DateInputService.spec.ts
@@ -14,8 +14,9 @@
*/
import { describe, expect, it } from 'vitest';
+import { Temporal } from 'temporal-polyfill';
-import { getDateSegments } from './DateInputService.js';
+import { getCalendarButtonLabel, getDateSegments } from './DateInputService.js';
describe('DateInputService', () => {
describe('getDateSegments', () => {
@@ -43,4 +44,29 @@ describe('DateInputService', () => {
expect(literalSegment?.value).toBe(literal);
});
});
+
+ describe('getCalendarButtonLabel', () => {
+ const label = 'Change date';
+
+ it('should return the plain label if the date is undefined', () => {
+ const date = undefined;
+ const locale = undefined;
+ const actual = getCalendarButtonLabel(label, date, locale);
+ expect(actual).toBe(label);
+ });
+
+ it('should postfix the formatted date to the label', () => {
+ const date = new Temporal.PlainDate(2017, 8, 28);
+ const locale = undefined;
+ const actual = getCalendarButtonLabel(label, date, locale);
+ expect(actual).toBe(`${label}, August 28, 2017`);
+ });
+
+ it('should format the date for the locale', () => {
+ const date = new Temporal.PlainDate(2017, 8, 28);
+ const locale = 'fr-FR';
+ const actual = getCalendarButtonLabel(label, date, locale);
+ expect(actual).toBe(`${label}, 28 août 2017`);
+ });
+ });
});