1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
triggerPopTest.js 1.8 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
ZQD Отправлено 5 лет назад 0059575
import React from 'react';
import { mount } from 'enzyme';
export default function triggerPopTest(Component) {
describe('Trigger Pop Test', () => {
beforeAll(() => {
jest.useFakeTimers();
});
let container;
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});
afterAll(() => {
jest.useRealTimers();
});
afterEach(() => {
document.body.removeChild(container);
});
it('the Popup change event will trigger when {click, mousedown,mousemove,mouseenter,contextmenu }', () => {
const handlePopupChange = jest.fn();
const wrapper = mount(<Component onPopupHiddenChange={handlePopupChange} />);
expect(handlePopupChange).not.toHaveBeenCalled();
wrapper.find('input').simulate('click');
jest.runAllTimers();
expect(handlePopupChange).toHaveBeenCalled();
wrapper.find('input').simulate('mousedown');
jest.runAllTimers();
expect(handlePopupChange).toHaveBeenCalled();
wrapper.find('input').simulate('mouseenter');
jest.runAllTimers();
expect(handlePopupChange).toHaveBeenCalled();
wrapper.find('input').simulate('mousemove');
jest.runAllTimers();
expect(handlePopupChange).toHaveBeenCalled();
wrapper.find('input').simulate('contextmenu');
jest.runAllTimers();
expect(handlePopupChange).toHaveBeenCalled();
});
it('the Popup change can not trigger when the property readonly is true', () => {
const handlePopupChange = jest.fn();
const wrapper = mount(<Component onPopupHiddenChange={handlePopupChange} />);
wrapper.setProps({ readOnly: true });
wrapper.find('input').simulate('click');
jest.runAllTimers();
expect(handlePopupChange).not.toHaveBeenCalled();
});
});
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/open-hand-choerodon-ui.git
git@gitlife.ru:oschina-mirror/open-hand-choerodon-ui.git
oschina-mirror
open-hand-choerodon-ui
open-hand-choerodon-ui
1.4.4