import { renderHook } from '@testing-library/react-hooks'; import { useFormLabelAlign } from '../use-form-label-align'; /** * 测试非中文简繁场景,如英文 */ jest.mock('@cainiaofe/cn-i18n', () => ({ getLang: () => 'zh-CN', })); describe('useFormLabelAlign 中文场景', () => { it('当 labelAlign 为 auto,且是中文的时候,返回值为 left', () => { const { result } = renderHook(() => useFormLabelAlign('auto')); expect(result.current).toBe('left'); }); it('当 labelAlign 为 top,且是中文的时候,返回值为 top', () => { const { result } = renderHook(() => useFormLabelAlign('top')); expect(result.current).toBe('top'); }); it('当 labelAlign 为 left,且是中文的时候,返回值为 left', () => { const { result } = renderHook(() => useFormLabelAlign('left')); expect(result.current).toBe('left'); }); });