File "normalizeKey.test.ts"
Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/dom/normalizeKey/normalizeKey.test.ts
File
size: 939 B (939 B bytes)
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor Back
import { fire } from '../../../test';
import { NORMALIZATION_MAP, normalizeKey } from './normalizeKey';
describe( 'normalizeKey', () => {
test( 'can normalize a key into a standard name.', () => {
const keys = Object.keys( NORMALIZATION_MAP );
const callback = jest.fn();
keys.forEach( key => {
expect( normalizeKey( key ) ).toBe( NORMALIZATION_MAP[ key ] );
callback();
} );
expect( callback ).toHaveBeenCalled();
} );
test( 'can return a normalized key from a Keyboard event object.', done => {
window.addEventListener( 'keydown', e => {
expect( normalizeKey( e ) ).toBe( 'ArrowUp' );
done();
} );
fire( window, 'keydown', { key: 'Up' } );
} );
test( 'should do the provided key as is if the normalization map does not include the passed key.', () => {
expect( normalizeKey( 'a' ) ).toBe( 'a' );
expect( normalizeKey( 'F1' ) ).toBe( 'F1' );
} );
} );