|
| 1 | +import React, { FC } from 'react' |
| 2 | +import { renderHook } from '@testing-library/react-hooks' |
| 3 | + |
| 4 | +import { FormContext } from '../../components' |
| 5 | +import { useInput } from '../useInput' |
| 6 | +import mockTextSchema from '../__mocks__/mockTextSchema' |
| 7 | + |
| 8 | +const Wrapper: FC = ({ children }) => { |
| 9 | + return <FormContext schema={mockTextSchema}>{children}</FormContext> |
| 10 | +} |
| 11 | + |
| 12 | +test('useInput type date', () => { |
| 13 | + const { result } = renderHook(() => useInput('#/properties/stringDateTest'), { |
| 14 | + wrapper: Wrapper, |
| 15 | + }) |
| 16 | + |
| 17 | + const { type } = result.current.getInputProps() |
| 18 | + expect(type).toBe('date') |
| 19 | +}) |
| 20 | + |
| 21 | +test('useInput type date-time', () => { |
| 22 | + const { result } = renderHook( |
| 23 | + () => useInput('#/properties/stringDateTimeTest'), |
| 24 | + { |
| 25 | + wrapper: Wrapper, |
| 26 | + } |
| 27 | + ) |
| 28 | + |
| 29 | + const { type } = result.current.getInputProps() |
| 30 | + expect(type).toBe('datetime-local') |
| 31 | +}) |
| 32 | + |
| 33 | +test('useInput type email', () => { |
| 34 | + const { result } = renderHook( |
| 35 | + () => useInput('#/properties/stringEmailTest'), |
| 36 | + { |
| 37 | + wrapper: Wrapper, |
| 38 | + } |
| 39 | + ) |
| 40 | + |
| 41 | + const { type } = result.current.getInputProps() |
| 42 | + expect(type).toBe('email') |
| 43 | +}) |
| 44 | + |
| 45 | +test('useInput type hostname', () => { |
| 46 | + const { result } = renderHook( |
| 47 | + () => useInput('#/properties/stringHostnameTest'), |
| 48 | + { |
| 49 | + wrapper: Wrapper, |
| 50 | + } |
| 51 | + ) |
| 52 | + |
| 53 | + const { type } = result.current.getInputProps() |
| 54 | + expect(type).toBe('url') |
| 55 | +}) |
| 56 | + |
| 57 | +test('useInput type uri', () => { |
| 58 | + const { result } = renderHook(() => useInput('#/properties/stringUriTest'), { |
| 59 | + wrapper: Wrapper, |
| 60 | + }) |
| 61 | + |
| 62 | + const { type } = result.current.getInputProps() |
| 63 | + expect(type).toBe('url') |
| 64 | +}) |
0 commit comments