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

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
focusTest.js 1.3 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
HughHzWu Отправлено 6 лет назад 951db21
import React from 'react';
import { mount } from 'enzyme';
export default function focusTest(Component) {
describe('focus and blur', () => {
beforeAll(() => {
jest.useFakeTimers();
});
let container;
beforeEach(() => {
container = document.createElement('div');
document.body.appendChild(container);
});
afterAll(() => {
jest.useRealTimers();
});
afterEach(() => {
document.body.removeChild(container);
});
it('focus() and onFocus', () => {
const handleFocus = jest.fn();
const wrapper = mount(<Component onFocus={handleFocus} />, { attachTo: container });
wrapper.instance().focus();
jest.runAllTimers();
expect(handleFocus).toHaveBeenCalled();
});
it('blur() and onBlur', () => {
const handleBlur = jest.fn();
const wrapper = mount(<Component onBlur={handleBlur} />, { attachTo: container });
wrapper.instance().focus();
jest.runAllTimers();
wrapper.instance().blur();
jest.runAllTimers();
expect(handleBlur).toHaveBeenCalled();
});
it('autoFocus', () => {
const handleFocus = jest.fn();
mount(<Component autoFocus onFocus={handleFocus} />, { attachTo: container });
jest.runAllTimers();
expect(handleFocus).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.1