import React, { useState } from 'react';
import { mount } from 'enzyme';
import { SmileOutlined } from '@ant-design/icons';
import ConfigProvider, { ConfigContext } from '..';
import Button from '../../button';
import Table from '../../table';
import Input from '../../input';
import mountTest from '../../../tests/shared/mountTest';
describe('ConfigProvider', () => {
mountTest(() => (
));
it('Content Security Policy', () => {
const csp = { nonce: 'test-antd' };
const wrapper = mount(
,
);
expect(wrapper.find('Wave').instance().csp).toBe(csp);
});
it('autoInsertSpaceInButton', () => {
const wrapper = mount(
,
);
expect(wrapper.find('Button').text()).toBe('确定');
});
it('renderEmpty', () => {
const wrapper = mount(
empty placeholder
}>
,
);
expect(wrapper.text()).toContain('empty placeholder');
});
it('nest prefixCls', () => {
const wrapper = mount(
,
);
expect(wrapper.find('button').props().className).toEqual('bamboo-btn');
});
it('dynamic prefixCls', () => {
const DynamicPrefixCls = () => {
const [prefixCls, setPrefixCls] = useState('bamboo');
return (
);
};
const wrapper = mount();
expect(wrapper.find('button').last().props().className).toEqual('bamboo-btn');
wrapper.find('.toggle-button').first().simulate('click');
expect(wrapper.find('button').last().props().className).toEqual('light-btn');
});
it('iconPrefixCls', () => {
const wrapper = mount(
,
);
expect(wrapper.find('[role="img"]').hasClass('bamboo')).toBeTruthy();
expect(wrapper.find('[role="img"]').hasClass('bamboo-smile')).toBeTruthy();
});
it('input autoComplete', () => {
const wrapper = mount(
,
);
expect(wrapper.find('input').props().autoComplete).toEqual('off');
});
it('render empty', () => {
const App = () => {
const { renderEmpty } = React.useContext(ConfigContext);
return renderEmpty();
};
const wrapper = mount(
,
);
expect(wrapper).toMatchRenderedSnapshot();
});
});