You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.2 KiB
60 lines
1.2 KiB
3 years ago
|
import message, { actWrapper, actDestroy } from '..';
|
||
|
import { act } from '../../../tests/utils';
|
||
|
import { awaitPromise, triggerMotionEnd } from './util';
|
||
|
|
||
|
describe('call close immediately', () => {
|
||
|
beforeAll(() => {
|
||
|
actWrapper(act);
|
||
|
});
|
||
|
|
||
|
beforeEach(() => {
|
||
|
actDestroy();
|
||
|
jest.useFakeTimers();
|
||
|
});
|
||
|
|
||
|
afterEach(async () => {
|
||
|
// Clean up
|
||
|
message.destroy();
|
||
|
await triggerMotionEnd();
|
||
|
|
||
|
act(() => {
|
||
|
jest.runAllTimers();
|
||
|
});
|
||
|
|
||
|
jest.useRealTimers();
|
||
|
|
||
|
await awaitPromise();
|
||
|
});
|
||
|
|
||
|
it('open', async () => {
|
||
|
const closeFn = message.open({
|
||
|
content: '',
|
||
|
});
|
||
|
closeFn();
|
||
|
|
||
|
await awaitPromise();
|
||
|
|
||
|
expect(document.querySelectorAll('.ant-message-notice')).toHaveLength(0);
|
||
|
|
||
|
// Created close
|
||
|
const closeFn2 = message.open({
|
||
|
content: 'showed',
|
||
|
});
|
||
|
await awaitPromise();
|
||
|
expect(document.querySelectorAll('.ant-message-notice')).toHaveLength(1);
|
||
|
|
||
|
closeFn2();
|
||
|
await triggerMotionEnd();
|
||
|
expect(document.querySelectorAll('.ant-message-notice')).toHaveLength(0);
|
||
|
});
|
||
|
|
||
|
it('info', async () => {
|
||
|
const closeFn = message.info('Message1', 0);
|
||
|
closeFn();
|
||
|
|
||
|
await awaitPromise();
|
||
|
|
||
|
expect(document.querySelectorAll('.ant-message-notice')).toHaveLength(0);
|
||
|
});
|
||
|
});
|