mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
chore: Transform alert test to typescript (#23495)
This commit is contained in:
parent
b7e877aeef
commit
800871166c
@ -39,20 +39,20 @@ describe('Alert', () => {
|
|||||||
|
|
||||||
describe('data and aria props', () => {
|
describe('data and aria props', () => {
|
||||||
it('sets data attributes on input', () => {
|
it('sets data attributes on input', () => {
|
||||||
const wrapper = mount(<Alert data-test="test-id" data-id="12345" />);
|
const wrapper = mount(<Alert data-test="test-id" data-id="12345" message={null} />);
|
||||||
const input = wrapper.find('.ant-alert').getDOMNode();
|
const input = wrapper.find('.ant-alert').getDOMNode();
|
||||||
expect(input.getAttribute('data-test')).toBe('test-id');
|
expect(input.getAttribute('data-test')).toBe('test-id');
|
||||||
expect(input.getAttribute('data-id')).toBe('12345');
|
expect(input.getAttribute('data-id')).toBe('12345');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets aria attributes on input', () => {
|
it('sets aria attributes on input', () => {
|
||||||
const wrapper = mount(<Alert aria-describedby="some-label" />);
|
const wrapper = mount(<Alert aria-describedby="some-label" message={null} />);
|
||||||
const input = wrapper.find('.ant-alert').getDOMNode();
|
const input = wrapper.find('.ant-alert').getDOMNode();
|
||||||
expect(input.getAttribute('aria-describedby')).toBe('some-label');
|
expect(input.getAttribute('aria-describedby')).toBe('some-label');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets role attribute on input', () => {
|
it('sets role attribute on input', () => {
|
||||||
const wrapper = mount(<Alert role="status" />);
|
const wrapper = mount(<Alert role="status" message={null} />);
|
||||||
const input = wrapper.find('.ant-alert').getDOMNode();
|
const input = wrapper.find('.ant-alert').getDOMNode();
|
||||||
expect(input.getAttribute('role')).toBe('status');
|
expect(input.getAttribute('role')).toBe('status');
|
||||||
});
|
});
|
||||||
@ -60,6 +60,8 @@ describe('Alert', () => {
|
|||||||
|
|
||||||
const testIt = process.env.REACT === '15' ? it.skip : it;
|
const testIt = process.env.REACT === '15' ? it.skip : it;
|
||||||
testIt('ErrorBoundary', () => {
|
testIt('ErrorBoundary', () => {
|
||||||
|
// TODO: Change to @ts-expect-error once typescript is at 3.9
|
||||||
|
// @ts-ignore
|
||||||
// eslint-disable-next-line react/jsx-no-undef
|
// eslint-disable-next-line react/jsx-no-undef
|
||||||
const ThrowError = () => <NotExisted />;
|
const ThrowError = () => <NotExisted />;
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
@ -83,12 +85,7 @@ describe('Alert', () => {
|
|||||||
);
|
);
|
||||||
wrapper.find('.ant-alert').simulate('mouseenter');
|
wrapper.find('.ant-alert').simulate('mouseenter');
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
expect(
|
expect(wrapper.find<Tooltip>(Tooltip).instance().getPopupDomNode()).toBeTruthy();
|
||||||
wrapper
|
|
||||||
.find(Tooltip)
|
|
||||||
.instance()
|
|
||||||
.getPopupDomNode(),
|
|
||||||
).toBeTruthy();
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -104,12 +101,7 @@ describe('Alert', () => {
|
|||||||
);
|
);
|
||||||
wrapper.find('.ant-alert').simulate('click');
|
wrapper.find('.ant-alert').simulate('click');
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
expect(
|
expect(wrapper.find<Popconfirm>(Popconfirm).instance().getPopupDomNode()).toBeTruthy();
|
||||||
wrapper
|
|
||||||
.find(Popconfirm)
|
|
||||||
.instance()
|
|
||||||
.getPopupDomNode(),
|
|
||||||
).toBeTruthy();
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -37,6 +37,8 @@ export interface AlertProps {
|
|||||||
afterClose?: () => void;
|
afterClose?: () => void;
|
||||||
/** Whether to show icon */
|
/** Whether to show icon */
|
||||||
showIcon?: boolean;
|
showIcon?: boolean;
|
||||||
|
/** https://www.w3.org/TR/2014/REC-html5-20141028/dom.html#aria-role-attribute */
|
||||||
|
role?: string;
|
||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
prefixCls?: string;
|
prefixCls?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user