import React from 'react'; import ConfigProvider from '..'; import { resetWarned } from '../../_util/warning'; import { render } from '../../../tests/utils'; import Form from '../../form'; describe('ConfigProvider.useConfig', () => { it('useConfig - componentSize', () => { let size; const App: React.FC = () => { const { componentSize } = ConfigProvider.useConfig(); size = componentSize; return null; }; render( , ); expect(size).toBe('small'); }); it('useConfig - componentDisabled', () => { let disabled; const App: React.FC = () => { const { componentDisabled } = ConfigProvider.useConfig(); disabled = componentDisabled; return null; }; render(
, ); expect(disabled).toBe(true); }); it('deprecated SizeContext', () => { resetWarned(); const App: React.FC = () => { const { SizeContext } = ConfigProvider; const ctx = React.useContext(SizeContext); return
{ctx}
; }; const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); expect(errSpy).toHaveBeenCalledWith( 'Warning: [antd: ConfigProvider] ConfigProvider.SizeContext is deprecated. Please use `ConfigProvider.useConfig().componentSize` instead.', ); errSpy.mockRestore(); }); });