mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 22:11:37 +08:00
2341a25d91
* more refactor * chore: motion support * chore: tmp test * test: Hooks * chore: static function * tmp of it * all of it * mv prefix * chore: clean up * chore: clean up * more test case * test: all base test * test: all test case * init * refactor: rm notification.open instance related code * follow up * refactor: singlton * test: notification test case * refactor to destroy * refactor: message base * test: part test case * test: more * test: more * test: all test * chore: clean up * docs: reorder * chore: fix lint * test: fix test case * chore: add act * chore: back * chore: fix style * test: notification test * test: more and more * test: fix more test * test: index * test: more & more * test: fix placement * test: fix coverage * chore: clean up * chore: bundle size * fix: 17 * chore: more * test: message * test: more test * fix: lint * test: rm class in static * chore: clean up * test: coverage * chore: fix lint
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
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);
|
|
});
|
|
});
|