import { describe, expectTypeOf, test } from 'vitest' import type { NotFoundRouteProps, RegisteredRouter, RouteIds } from '../src' describe('NotFoundRouteProps', () => { test('should have correct basic property types', () => { expectTypeOf().toEqualTypeOf< unknown | undefined >() expectTypeOf().toEqualTypeOf() expectTypeOf().toEqualTypeOf< RouteIds >() }) test('should have data as optional property', () => { expectTypeOf().toMatchTypeOf<{ data?: unknown isNotFound: boolean routeId: RouteIds }>() }) test('should have isNotFound as required property', () => { expectTypeOf>().toEqualTypeOf<{ isNotFound: boolean }>() }) test('should have routeId as required property', () => { expectTypeOf>().toEqualTypeOf<{ routeId: RouteIds }>() }) test('should be assignable with minimal required properties', () => { const props: NotFoundRouteProps = { isNotFound: true, routeId: '/' as RouteIds, } expectTypeOf(props).toMatchTypeOf() }) test('should be assignable with all properties', () => { const props: NotFoundRouteProps = { data: { message: 'Not found' }, isNotFound: true, routeId: '/' as RouteIds, } expectTypeOf(props).toMatchTypeOf() }) test('should accept any data type', () => { const propsWithString: NotFoundRouteProps = { data: 'string data', isNotFound: true, routeId: '/' as RouteIds, } expectTypeOf(propsWithString).toMatchTypeOf() const propsWithObject: NotFoundRouteProps = { data: { userId: 123, message: 'User not found' }, isNotFound: true, routeId: '/users' as RouteIds, } expectTypeOf(propsWithObject).toMatchTypeOf() const propsWithArray: NotFoundRouteProps = { data: [1, 2, 3], isNotFound: true, routeId: '/' as RouteIds, } expectTypeOf(propsWithArray).toMatchTypeOf() }) test('should accept undefined data', () => { const props: NotFoundRouteProps = { data: undefined, isNotFound: true, routeId: '/' as RouteIds, } expectTypeOf(props).toMatchTypeOf() }) test('notFoundComponent should accept NotFoundRouteProps', () => { type NotFoundComponent = (props: NotFoundRouteProps) => any const component: NotFoundComponent = (props) => { expectTypeOf(props.data).toEqualTypeOf() expectTypeOf(props.isNotFound).toEqualTypeOf() expectTypeOf(props.routeId).toEqualTypeOf< RouteIds >() return null } expectTypeOf(component).toMatchTypeOf() }) test('defaultNotFoundComponent should accept NotFoundRouteProps', () => { type DefaultNotFoundComponent = (props: NotFoundRouteProps) => any const component: DefaultNotFoundComponent = (props) => { expectTypeOf(props).toMatchTypeOf() return null } expectTypeOf(component).toMatchTypeOf() }) test('should be spreadable as component props', () => { const notFoundData = { data: { message: 'Custom error' }, isNotFound: true as const, routeId: '/' as RouteIds, } type SpreadProps = typeof notFoundData expectTypeOf().toMatchTypeOf() const component = (props: NotFoundRouteProps) => { expectTypeOf(props).toMatchTypeOf() return null } expectTypeOf(component).parameter(0).toMatchTypeOf() }) test('should maintain type safety with spread', () => { const data: NotFoundRouteProps = { data: { userId: 123 }, isNotFound: true, routeId: '/users' as RouteIds, } const spreadData = { ...data } expectTypeOf(spreadData).toMatchTypeOf() }) })