Browse Source
* feat: add style/className/styles/classNames to ConfigProvider * chore: better code * Update components/config-provider/index.en-US.md Co-authored-by: lijianan <574980606@qq.com> * Update components/config-provider/index.zh-CN.md Co-authored-by: lijianan <574980606@qq.com> --------- Co-authored-by: 歆其 <luzhenjie.lzj@antgroup.com> Co-authored-by: MadCcc <1075746765@qq.com> Co-authored-by: lijianan <574980606@qq.com>pull/42659/head
LuZhenJie1999
2 years ago
committed by
GitHub
6 changed files with 83 additions and 5 deletions
@ -0,0 +1,53 @@ |
|||
import { SearchOutlined } from '@ant-design/icons'; |
|||
import Button from 'antd/es/button'; |
|||
import React from 'react'; |
|||
import ConfigProvider from '..'; |
|||
import { render } from '../../../tests/utils'; |
|||
|
|||
describe('ConfigProvider.button', () => { |
|||
beforeEach(() => { |
|||
(global as any).triggerProps = null; |
|||
}); |
|||
|
|||
it('ConfigProvider button style', () => { |
|||
const { container } = render( |
|||
<ConfigProvider> |
|||
<Button style={{ fontSize: '14px' }} /> |
|||
</ConfigProvider>, |
|||
); |
|||
|
|||
const item = container.querySelector('button') as HTMLElement; |
|||
expect(getComputedStyle(item)?.fontSize).toBe('14px'); |
|||
}); |
|||
|
|||
it('ConfigProvider button className', () => { |
|||
const { container } = render( |
|||
<ConfigProvider> |
|||
<Button className="custom-class" /> |
|||
</ConfigProvider>, |
|||
); |
|||
|
|||
expect(container.querySelector('button')?.className.includes('custom-class')).toBe(true); |
|||
}); |
|||
|
|||
it('ConfigProvider button styles', () => { |
|||
const { container } = render( |
|||
<ConfigProvider button={{ styles: { icon: { color: '#333' } } }}> |
|||
<Button icon={<SearchOutlined />} /> |
|||
</ConfigProvider>, |
|||
); |
|||
|
|||
const item = container.querySelector('.ant-btn-icon') as HTMLElement; |
|||
expect(getComputedStyle(item)?.fontSize).toBe('14px'); |
|||
}); |
|||
|
|||
it('ConfigProvider button classNames', () => { |
|||
const { container } = render( |
|||
<ConfigProvider button={{ classNames: { icon: 'icon-custom-class' } }}> |
|||
<Button icon={<SearchOutlined />} /> |
|||
</ConfigProvider>, |
|||
); |
|||
|
|||
expect(container.querySelector('.ant-btn-icon')?.className.includes('custom-class')).toBe(true); |
|||
}); |
|||
}); |
Loading…
Reference in new issue