forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseField.test.tsx
More file actions
45 lines (40 loc) · 1.26 KB
/
useField.test.tsx
File metadata and controls
45 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { useField_unstable } from './useField';
describe('useField_unstable', () => {
const ref = React.createRef<HTMLDivElement>();
it('should return default state when no props are provided', () => {
const { result } = renderHook(() => useField_unstable({}, ref));
expect(result.current).toMatchObject({
children: undefined,
orientation: 'vertical',
components: {
label: expect.objectContaining({}),
},
size: 'medium',
label: undefined,
validationMessageIcon: undefined,
validationState: 'none',
});
});
it('should return state when props are provided', () => {
const { result } = renderHook(() =>
useField_unstable(
{
orientation: 'horizontal',
size: 'small',
label: 'Test Label',
validationState: 'error',
},
ref,
),
);
expect(result.current).toMatchObject({
orientation: 'horizontal',
size: 'small',
label: expect.objectContaining({ children: 'Test Label' }),
validationMessageIcon: expect.objectContaining({ children: expect.objectContaining({}) }),
validationState: 'error',
});
});
});