import React from 'react'; import { mount } from 'enzyme'; import Alert from '..'; describe('Alert', () => { beforeAll(() => { jest.useFakeTimers(); }); afterAll(() => { jest.useRealTimers(); }); it('could be closed', () => { const onClose = jest.fn(); const afterClose = jest.fn(); const wrapper = mount( ); wrapper.find('.ant-alert-close-icon').simulate('click'); expect(onClose).toBeCalled(); jest.runAllTimers(); expect(afterClose).toBeCalled(); }); });