Download wp-calypso/packages/accessible-focus/src/test/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/accessible-focus/src/test/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/accessible-focus/src/test/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/accessible-focus/src/test/index.js
1.61 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { detectKeyboardNavigation } from '..'; | |
| describe( 'detectKeyboardNavigation', () => { | |
| describe( 'keyCode', () => { | |
| it.each( [ 9, 32, 37, 38, 39, 40 ] )( | |
| 'should return true when the keyCode is %s', | |
| ( keyCode ) => { | |
| const event = { | |
| keyCode, | |
| }; | |
| expect( detectKeyboardNavigation( event ) ).toBeTruthy(); | |
| } | |
| ); | |
| it( 'should be false when keyCode does not indicate keyboard navigation', () => { | |
| const event = { | |
| keyCode: 46, // delete | |
| }; | |
| expect( detectKeyboardNavigation( event ) ).toBeFalsy(); | |
| } ); | |
| } ); | |
| describe( 'keyIdentifier', () => { | |
| it.each( [ 'Tab', ' ', 'Spacebar', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ] )( | |
| 'should return true when keyIdenitifer is "%s"', | |
| ( keyIdentifier ) => { | |
| const event = { | |
| keyIdentifier, | |
| }; | |
| expect( detectKeyboardNavigation( event ) ).toBeTruthy(); | |
| } | |
| ); | |
| it( 'should be false when keyIdentifier does not indicate keyboard navigation', () => { | |
| const event = { | |
| keyIdenitifer: 'Delete', | |
| }; | |
| expect( detectKeyboardNavigation( event ) ).toBeFalsy(); | |
| } ); | |
| } ); | |
| describe( 'key', () => { | |
| it.each( [ 'Tab', ' ', 'Spacebar', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ] )( | |
| 'should return true when key is "%s"', | |
| ( key ) => { | |
| const event = { key }; | |
| expect( detectKeyboardNavigation( event ) ).toBeTruthy(); | |
| } | |
| ); | |
| it( 'should be false when key does not indicate keyboard navigation', () => { | |
| const event = { key: 'Delete' }; | |
| expect( detectKeyboardNavigation( event ) ).toBeFalsy(); | |
| } ); | |
| } ); | |
| } ); | |