@@ -83,32 +83,6 @@ describe('EuiKeyboardAccessible', () => {
8383 `child's onClick prop needs to be a function.`
8484 ) ;
8585 } ) ;
86-
87- test ( `when the child has an onKeyDown prop` , ( ) => {
88- const component = ( // eslint-disable-line no-unused-vars
89- < EuiKeyboardAccessible >
90- < div onClick = { ( ) => { } } onKeyDown = { ( ) => { } } />
91- </ EuiKeyboardAccessible >
92- ) ;
93-
94- expect ( consoleStub . calledOnce ) . toBe ( true ) ;
95- expect ( consoleStub . getCall ( 0 ) . args [ 0 ] ) . toContain (
96- `child can't have an onKeyDown prop because the implementation will override it.`
97- ) ;
98- } ) ;
99-
100- test ( `when the child has an onKeyUp prop` , ( ) => {
101- const component = ( // eslint-disable-line no-unused-vars
102- < EuiKeyboardAccessible >
103- < div onClick = { ( ) => { } } onKeyUp = { ( ) => { } } />
104- </ EuiKeyboardAccessible >
105- ) ;
106-
107- expect ( consoleStub . calledOnce ) . toBe ( true ) ;
108- expect ( consoleStub . getCall ( 0 ) . args [ 0 ] ) . toContain (
109- `child can't have an onKeyUp prop because the implementation will override it.`
110- ) ;
111- } ) ;
11286 } ) ;
11387
11488 describe ( `doesn't throw an error` , ( ) => {
@@ -195,4 +169,38 @@ describe('EuiKeyboardAccessible', () => {
195169 sinon . assert . calledOnce ( onClickHandler ) ;
196170 } ) ;
197171 } ) ;
172+
173+ describe ( `child's props` , ( ) => {
174+ test ( `onKeyUp handler is called` , ( ) => {
175+ const onKeyUpHandler = sinon . stub ( ) ;
176+
177+ const $button = shallow (
178+ < EuiKeyboardAccessible >
179+ < div data-div onKeyUp = { onKeyUpHandler } />
180+ </ EuiKeyboardAccessible >
181+ ) ;
182+
183+ $button . find ( '[data-div]' ) . simulate ( 'keyup' , {
184+ keyCode : 0 ,
185+ } ) ;
186+
187+ sinon . assert . calledOnce ( onKeyUpHandler ) ;
188+ } ) ;
189+
190+ test ( `onKeyDown handler is called` , ( ) => {
191+ const onKeyDownHandler = sinon . stub ( ) ;
192+
193+ const $button = shallow (
194+ < EuiKeyboardAccessible >
195+ < div data-div onKeyDown = { onKeyDownHandler } />
196+ </ EuiKeyboardAccessible >
197+ ) ;
198+
199+ $button . find ( '[data-div]' ) . simulate ( 'keydown' , {
200+ keyCode : 0 ,
201+ } ) ;
202+
203+ sinon . assert . calledOnce ( onKeyDownHandler ) ;
204+ } ) ;
205+ } ) ;
198206} ) ;
0 commit comments