From 2855ae35254c2d8519d9254ca81f39b86bb43e08 Mon Sep 17 00:00:00 2001 From: galiprandi <20272796+galiprandi@users.noreply.github.com> Date: Tue, 9 Jun 2026 04:26:10 +0000 Subject: [PATCH] quality: fix lint and improve coverage in DateTime component --- lib/components/DateTime/index.test.tsx | 37 +++++++++++++++++++++++++- lib/components/DateTime/index.tsx | 2 ++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/components/DateTime/index.test.tsx b/lib/components/DateTime/index.test.tsx index 1941624..39b8d94 100644 --- a/lib/components/DateTime/index.test.tsx +++ b/lib/components/DateTime/index.test.tsx @@ -1,6 +1,6 @@ import { describe, it, expect, beforeEach, vi } from 'vitest' import { render, cleanup, fireEvent } from '@testing-library/react' -import { DateTime } from '../../main.ts' +import { DateTime } from './index' import { iso2LocalDateTime } from '../../utilities/dates' describe('', () => { @@ -146,4 +146,39 @@ describe('', () => { const expectedUpdatedLocal = iso2LocalDateTime('2021-01-02T01:00:00Z') expect(input.value).toBe(expectedUpdatedLocal) }) + + it('should use standard min and max props when isoMin and isoMax are not provided', () => { + const { getByTestId } = render( + , + ) + const input = getByTestId('test-minmax') as HTMLInputElement + expect(input.min).toBe('2021-01-01T00:00') + expect(input.max).toBe('2021-12-31T23:59') + }) + + it('should use value prop when isoValue is not provided', () => { + const { getByTestId } = render( + , + ) + const input = getByTestId('test-value') as HTMLInputElement + expect(input.value).toBe('2021-01-01T00:00') + }) + + it('should handle invalid isoValue', () => { + const onChangeISOValue = vi.fn() + render( + , + ) + expect(onChangeISOValue).not.toHaveBeenCalled() + }) }) diff --git a/lib/components/DateTime/index.tsx b/lib/components/DateTime/index.tsx index e9b053b..46a6ed0 100644 --- a/lib/components/DateTime/index.tsx +++ b/lib/components/DateTime/index.tsx @@ -68,6 +68,8 @@ export const DateTime = forwardRef((props, ref) ) }) +DateTime.displayName = 'DateTime' + /** * The properties for the DateTime component. *