('style'));
expect(styles[styles.length - 1].nonce).toEqual(csp.nonce);
jest.useRealTimers();
});
it('autoInsertSpaceInButton', () => {
const text = '确定';
const { container } = render(
,
);
expect(container.querySelector('span')?.innerHTML).toBe(text);
});
it('renderEmpty', () => {
const text = 'empty placeholder';
const { container } = render(
{text}
}>
,
);
expect(container.querySelector('.ant-table-placeholder')?.querySelector('div')?.innerHTML).toBe(
text,
);
});
it('nest prefixCls', () => {
const { container } = render(
,
);
expect(container.querySelector('button.bamboo-btn')).toBeTruthy();
});
it('dynamic prefixCls', () => {
const DynamicPrefixCls: React.FC = () => {
const [prefixCls, setPrefixCls] = useState('bamboo');
return (
);
};
const { container } = render();
expect(container.querySelector('button.bamboo-btn')).toBeTruthy();
fireEvent.click(container.querySelector('.toggle-button')!);
expect(container.querySelector('button.light-btn')).toBeTruthy();
});
it('iconPrefixCls', () => {
const { container } = render(
,
);
expect(container.querySelector('[role="img"]')).toHaveClass('bamboo');
expect(container.querySelector('[role="img"]')).toHaveClass('bamboo-smile');
});
it('input autoComplete', () => {
const { container } = render(
,
);
expect(container.querySelector('input')?.autocomplete).toEqual('off');
});
it('select showSearch', () => {
const { container } = render(
,
);
expect(container.querySelectorAll('.ant-select-show-search').length).toBe(1);
});
it('render empty', () => {
let rendered = false;
let cacheRenderEmpty;
const App: React.FC = () => {
const { renderEmpty } = React.useContext(ConfigContext);
rendered = true;
cacheRenderEmpty = renderEmpty;
return null;
};
render(
,
);
expect(rendered).toBeTruthy();
expect(cacheRenderEmpty).toBeFalsy();
});
});