0
KeyDown 이벤트 - Shift 키를 누를 때 stopImmediatePropogation()을 테스트하려고합니다.효소 테스트/stopImmediatePropogation에 대한 keyDown (shift)에 대한 반응
enter// wrapper.simulate('keypress', { key: 'Shift' });
wrapper.simulate('keydown', { keyCode: 16 });
const stopPropogation = jest.fn();
expect(stopPropogation).toHaveBeenCalledTimes(0);
wrapper.find('.className').simulate('keyDown', { key: 'Shift' });
// const event = new KeyboardEvent('keydown', { keyCode: 16 });
// // const dispatchStopProp = jest.fn();
// document.dispatchEvent(event);
// // expect(dispatchStopProp).toHaveBeenCalledTimes(1);
// const result = wrapper.dive().instance().stopPropogation();
// expect(result).toEqual(1);
// const onKeyDown = sinon.spy();
// const wrapper = mount(<TestComponent onkeydown={onkeydown}/>);
// const input = wrapper.find('input');
// input.simulate('keyDown', { keyCode: 16 });
// expect(onKeyDown.called).to.be.true; code here
내 방식이 작동하지 않는 것 같습니다. 어떤 제안이 도움이 될 것입니다. 단위 테스트에
동기 : 키보드의 "변화"키가 앱 페이지에서 클릭 할 때
stopPropogation()가 호출된다.