|
|
@ -1,4 +1,3 @@
|
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
|
|
|
import message from '..';
|
|
|
|
import message from '..';
|
|
|
|
import SmileOutlined from '@ant-design/icons-vue/SmileOutlined';
|
|
|
|
import SmileOutlined from '@ant-design/icons-vue/SmileOutlined';
|
|
|
@ -59,7 +58,9 @@ describe('message', () => {
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(1);
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(1);
|
|
|
|
hide2();
|
|
|
|
hide2();
|
|
|
|
}, 0);
|
|
|
|
}, 0);
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(0);
|
|
|
|
await asyncExpect(() => {
|
|
|
|
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(0);
|
|
|
|
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should be able to destroy globally', async () => {
|
|
|
|
it('should be able to destroy globally', async () => {
|
|
|
@ -110,16 +111,7 @@ describe('message', () => {
|
|
|
|
|
|
|
|
|
|
|
|
// https:// github.com/ant-design/ant-design/issues/8201
|
|
|
|
// https:// github.com/ant-design/ant-design/issues/8201
|
|
|
|
it('should hide message correctly', async () => {
|
|
|
|
it('should hide message correctly', async () => {
|
|
|
|
let hide;
|
|
|
|
let hide = message.loading('Action in progress..', 0);
|
|
|
|
const Test = {
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
hide = message.loading('Action in progress..', 0);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
return <div>test</div>;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
mount(Test, { sync: false });
|
|
|
|
|
|
|
|
await asyncExpect(() => {
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(1);
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(1);
|
|
|
|
hide();
|
|
|
|
hide();
|
|
|
@ -129,7 +121,7 @@ describe('message', () => {
|
|
|
|
}, 0);
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('should allow custom icon', async () => {
|
|
|
|
it('should allow custom icon', async () => {
|
|
|
|
message.open({ content: 'Message', icon: h => <SmileOutlined /> }); // eslint-disable-line
|
|
|
|
message.open({ content: 'Message', icon: () => <SmileOutlined /> }); // eslint-disable-line
|
|
|
|
await asyncExpect(() => {
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(document.querySelectorAll('.anticon-smile').length).toBe(1);
|
|
|
|
expect(document.querySelectorAll('.anticon-smile').length).toBe(1);
|
|
|
|
}, 0);
|
|
|
|
}, 0);
|
|
|
@ -143,18 +135,9 @@ describe('message', () => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// https://github.com/ant-design/ant-design/issues/8201
|
|
|
|
// https://github.com/ant-design/ant-design/issues/8201
|
|
|
|
it('should destroy messages correctly', async () => {
|
|
|
|
it('should destroy messages correctly', async () => {
|
|
|
|
// eslint-disable-next-line
|
|
|
|
message.loading('Action in progress1..', 0);
|
|
|
|
const Test = {
|
|
|
|
message.loading('Action in progress2..', 0);
|
|
|
|
mounted() {
|
|
|
|
setTimeout(() => message.destroy(), 1000);
|
|
|
|
message.loading('Action in progress1..', 0);
|
|
|
|
|
|
|
|
message.loading('Action in progress2..', 0);
|
|
|
|
|
|
|
|
setTimeout(() => message.destroy(), 1000);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
return <div>test</div>;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
mount(Test, { sync: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await asyncExpect(() => {
|
|
|
|
await asyncExpect(() => {
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(2);
|
|
|
|
expect(document.querySelectorAll('.ant-message-notice').length).toBe(2);
|
|
|
|