(
done: Mocha.Done,
buttonProps: Partial<IButtonProps>,
keyEventProps: Partial<React.KeyboardEvent<any>>,
)
| 169 | } |
| 170 | |
| 171 | function checkClickTriggeredOnKeyUp( |
| 172 | done: Mocha.Done, |
| 173 | buttonProps: Partial<IButtonProps>, |
| 174 | keyEventProps: Partial<React.KeyboardEvent<any>>, |
| 175 | ) { |
| 176 | const wrapper = button(buttonProps, true); |
| 177 | |
| 178 | // mock the DOM click() function, because enzyme only handles |
| 179 | // simulated React events |
| 180 | const buttonRef = (wrapper.instance() as any).buttonRef; |
| 181 | const onClick = spy(buttonRef, "click"); |
| 182 | |
| 183 | wrapper.simulate("keyup", keyEventProps); |
| 184 | |
| 185 | // wait for the whole lifecycle to run |
| 186 | setTimeout(() => { |
| 187 | assert.equal(onClick.callCount, 1); |
| 188 | done(); |
| 189 | }, 0); |
| 190 | } |
| 191 | |
| 192 | function checkKeyEventCallbackInvoked(callbackPropName: string, eventName: string, keyCode: number) { |
| 193 | const callback = spy(); |
no test coverage detected