('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: RenderEmptyHandler | undefined;
const App: React.FC = () => {
const { renderEmpty } = React.useContext(ConfigContext);
rendered = true;
cacheRenderEmpty = renderEmpty;
return null;
};
render(
,
);
expect(rendered).toBeTruthy();
expect(cacheRenderEmpty).toBeFalsy();
});
it('warning support filter level', () => {
resetWarned();
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
render();
expect(errSpy).not.toHaveBeenCalled();
expect(warnSpy).toHaveBeenCalled();
errSpy.mockRestore();
warnSpy.mockRestore();
});
});