) => void;
}>({}).current;
if (freeze && !promiseCache.promise) {
promiseCache.promise = new Promise((resolve) => {
promiseCache.resolve = resolve;
});
throw promiseCache.promise;
}
if (freeze) {
throw promiseCache.promise;
}
if (promiseCache.promise) {
promiseCache.resolve?.();
promiseCache.promise = undefined;
}
return ;
}
const MyCom: React.FC = () => {
const [freeze, setFreeze] = useState(false);
return (
frozen>}>
);
};
const { container } = render();
fireEvent.click(container.querySelector('.change-btn')!);
expect(container.querySelector('.foo')).toHaveTextContent('frozen');
fireEvent.click(container.querySelector('.change-btn')!);
expect(container.querySelectorAll('.ant-btn-loading-icon').length).toBe(0);
});
// https://github.com/ant-design/ant-design/issues/45273
it('should display loading when delay is zero', () => {
const { container } = render();
expect(container.querySelectorAll('.ant-btn-loading').length).toBe(1);
});
// https://github.com/ant-design/ant-design/issues/47605
it('Compatible with original `type` behavior', async () => {
const { container } = render();
expect(container.querySelector('.ant-btn-default')).toBeTruthy();
});
it('should support autoInsertSpace', () => {
const text = '确定';
const { container } = render();
expect(container.querySelector('button')?.textContent).toBe(text);
});
it('should support solidTextColor when theme changes', () => {
const { container: defaultContainer } = render(
,
);
expect(defaultContainer.firstChild).toHaveStyle({
color: 'rgb(255, 255, 255)',
});
const { container: darkContainer } = render(
,
);
expect(darkContainer.firstChild).toHaveStyle({
color: 'rgb(0, 0, 0)',
});
});
});