mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-25 03:29:59 +08:00
test: fix Alert test (#33167)
* text: fix Alert test * test: style * test: up snap * test: up
This commit is contained in:
parent
a04a4efc8b
commit
499ee6c691
@ -1,238 +1,77 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Alert action of Alert custom action 1`] = `
|
||||
<Alert
|
||||
action={
|
||||
<Button
|
||||
size="small"
|
||||
type="text"
|
||||
>
|
||||
UNDO
|
||||
</Button>
|
||||
}
|
||||
closable={true}
|
||||
message="Success Tips"
|
||||
showIcon={true}
|
||||
type="success"
|
||||
<div
|
||||
class="ant-alert ant-alert-success"
|
||||
data-show="true"
|
||||
role="alert"
|
||||
>
|
||||
<CSSMotion
|
||||
motionAppear={false}
|
||||
motionEnter={false}
|
||||
motionName="ant-alert-motion"
|
||||
onLeaveStart={[Function]}
|
||||
visible={true}
|
||||
<span
|
||||
aria-label="check-circle"
|
||||
class="anticon anticon-check-circle ant-alert-icon"
|
||||
role="img"
|
||||
>
|
||||
<DomWrapper>
|
||||
<div
|
||||
className="ant-alert ant-alert-success"
|
||||
data-show={true}
|
||||
role="alert"
|
||||
style={Object {}}
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="check-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<div
|
||||
class="ant-alert-content"
|
||||
>
|
||||
<div
|
||||
class="ant-alert-message"
|
||||
>
|
||||
Success Tips
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-alert-action"
|
||||
>
|
||||
<button
|
||||
class="ant-btn ant-btn-text ant-btn-sm"
|
||||
type="button"
|
||||
>
|
||||
<span>
|
||||
UNDO
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
class="ant-alert-close-icon"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
aria-label="close"
|
||||
class="anticon anticon-close"
|
||||
role="img"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="close"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<ForwardRef(CheckCircleFilled)
|
||||
className="ant-alert-icon"
|
||||
>
|
||||
<AntdIcon
|
||||
className="ant-alert-icon"
|
||||
icon={
|
||||
Object {
|
||||
"icon": Object {
|
||||
"attrs": Object {
|
||||
"focusable": "false",
|
||||
"viewBox": "64 64 896 896",
|
||||
},
|
||||
"children": Array [
|
||||
Object {
|
||||
"attrs": Object {
|
||||
"d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z",
|
||||
},
|
||||
"tag": "path",
|
||||
},
|
||||
],
|
||||
"tag": "svg",
|
||||
},
|
||||
"name": "check-circle",
|
||||
"theme": "filled",
|
||||
}
|
||||
}
|
||||
>
|
||||
<span
|
||||
aria-label="check-circle"
|
||||
className="anticon anticon-check-circle ant-alert-icon"
|
||||
role="img"
|
||||
>
|
||||
<IconReact
|
||||
icon={
|
||||
Object {
|
||||
"icon": Object {
|
||||
"attrs": Object {
|
||||
"focusable": "false",
|
||||
"viewBox": "64 64 896 896",
|
||||
},
|
||||
"children": Array [
|
||||
Object {
|
||||
"attrs": Object {
|
||||
"d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z",
|
||||
},
|
||||
"tag": "path",
|
||||
},
|
||||
],
|
||||
"tag": "svg",
|
||||
},
|
||||
"name": "check-circle",
|
||||
"theme": "filled",
|
||||
}
|
||||
}
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="check-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
key="svg-check-circle"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
|
||||
key="svg-check-circle-svg-0"
|
||||
/>
|
||||
</svg>
|
||||
</IconReact>
|
||||
</span>
|
||||
</AntdIcon>
|
||||
</ForwardRef(CheckCircleFilled)>
|
||||
<div
|
||||
className="ant-alert-content"
|
||||
>
|
||||
<div
|
||||
className="ant-alert-message"
|
||||
>
|
||||
Success Tips
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="ant-alert-action"
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
type="text"
|
||||
>
|
||||
<button
|
||||
className="ant-btn ant-btn-text ant-btn-sm"
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
<LoadingIcon
|
||||
existIcon={false}
|
||||
loading={false}
|
||||
prefixCls="ant-btn"
|
||||
>
|
||||
<CSSMotion
|
||||
motionName="ant-btn-loading-icon-motion"
|
||||
onAppearActive={[Function]}
|
||||
onAppearStart={[Function]}
|
||||
onEnterActive={[Function]}
|
||||
onEnterStart={[Function]}
|
||||
onLeaveActive={[Function]}
|
||||
onLeaveStart={[Function]}
|
||||
removeOnLeave={true}
|
||||
visible={false}
|
||||
>
|
||||
<DomWrapper />
|
||||
</CSSMotion>
|
||||
</LoadingIcon>
|
||||
<span
|
||||
key=".0"
|
||||
>
|
||||
UNDO
|
||||
</span>
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
<button
|
||||
className="ant-alert-close-icon"
|
||||
onClick={[Function]}
|
||||
tabIndex={0}
|
||||
type="button"
|
||||
>
|
||||
<ForwardRef(CloseOutlined)>
|
||||
<AntdIcon
|
||||
icon={
|
||||
Object {
|
||||
"icon": Object {
|
||||
"attrs": Object {
|
||||
"focusable": "false",
|
||||
"viewBox": "64 64 896 896",
|
||||
},
|
||||
"children": Array [
|
||||
Object {
|
||||
"attrs": Object {
|
||||
"d": "M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z",
|
||||
},
|
||||
"tag": "path",
|
||||
},
|
||||
],
|
||||
"tag": "svg",
|
||||
},
|
||||
"name": "close",
|
||||
"theme": "outlined",
|
||||
}
|
||||
}
|
||||
>
|
||||
<span
|
||||
aria-label="close"
|
||||
className="anticon anticon-close"
|
||||
role="img"
|
||||
>
|
||||
<IconReact
|
||||
icon={
|
||||
Object {
|
||||
"icon": Object {
|
||||
"attrs": Object {
|
||||
"focusable": "false",
|
||||
"viewBox": "64 64 896 896",
|
||||
},
|
||||
"children": Array [
|
||||
Object {
|
||||
"attrs": Object {
|
||||
"d": "M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z",
|
||||
},
|
||||
"tag": "path",
|
||||
},
|
||||
],
|
||||
"tag": "svg",
|
||||
},
|
||||
"name": "close",
|
||||
"theme": "outlined",
|
||||
}
|
||||
}
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="close"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
key="svg-close"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
||||
key="svg-close-svg-0"
|
||||
/>
|
||||
</svg>
|
||||
</IconReact>
|
||||
</span>
|
||||
</AntdIcon>
|
||||
</ForwardRef(CloseOutlined)>
|
||||
</button>
|
||||
</div>
|
||||
</DomWrapper>
|
||||
</CSSMotion>
|
||||
</Alert>
|
||||
<path
|
||||
d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Alert could accept none react element icon 1`] = `
|
||||
|
@ -1,13 +1,13 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import Alert from '..';
|
||||
import Button from '../../button';
|
||||
import Tooltip from '../../tooltip';
|
||||
import Popconfirm from '../../popconfirm';
|
||||
import rtlTest from '../../../tests/shared/rtlTest';
|
||||
import accessibilityTest from '../../../tests/shared/accessibilityTest';
|
||||
import { sleep } from '../../../tests/utils';
|
||||
import Alert from '..';
|
||||
|
||||
const { ErrorBoundary } = Alert;
|
||||
|
||||
@ -57,12 +57,12 @@ describe('Alert', () => {
|
||||
closable
|
||||
/>,
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
it('support closeIcon', () => {
|
||||
const wrapper = render(
|
||||
const wrapper = mount(
|
||||
<Alert
|
||||
closable
|
||||
closeIcon={<span>close</span>}
|
||||
@ -70,7 +70,7 @@ describe('Alert', () => {
|
||||
type="warning"
|
||||
/>,
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('data and aria props', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user