Download wp-calypso/client/state/data-layer/test/handler-registry.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/test/handler-registry.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/test/handler-registry.js
-
curl -L -o handler-registry.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/test/handler-registry.js
1.34 kB
| import { getHandlers, registerHandlers, testReset } from '../handler-registry'; | |
| describe( 'handler loading', () => { | |
| beforeAll( testReset ); | |
| test( 'should not return anything on init', () => { | |
| expect( getHandlers( 'foo' ) ).toBeFalsy(); | |
| } ); | |
| test( 'should return handlers when loaded by type', () => { | |
| registerHandlers( 'birthday', { BIRTHDAY: [ () => 5 ] } ); | |
| expect( getHandlers( 'BIRTHDAY' )[ 0 ]() ).toEqual( 5 ); | |
| } ); | |
| test( 'should not return anything if no handlers associated to action type', () => { | |
| registerHandlers( 'birthday', { BIRTHDAY: [ () => 5 ] } ); | |
| expect( getHandlers( 'SHAMROCK' ) ).toBeFalsy(); | |
| } ); | |
| test( 'should only load handler sets once', () => { | |
| registerHandlers( 'birthday', { BIRTHDAY: [ () => 5 ] } ); | |
| registerHandlers( 'birthday', { BIRTHDAY: [ () => 7 ] } ); | |
| const handlers = getHandlers( 'BIRTHDAY' ); | |
| expect( handlers ).toHaveLength( 1 ); | |
| expect( handlers[ 0 ]() ).toEqual( 5 ); | |
| } ); | |
| test( 'should merge lists for different handler sets', () => { | |
| registerHandlers( 'birthday', { BIRTHDAY: [ () => 5 ] } ); | |
| registerHandlers( 'shamrock', { BIRTHDAY: [ () => 7 ] } ); | |
| const handlers = getHandlers( 'BIRTHDAY' ); | |
| expect( handlers ).toHaveLength( 2 ); | |
| expect( [ handlers[ 0 ](), handlers[ 1 ]() ] ).toEqual( expect.arrayContaining( [ 5, 7 ] ) ); | |
| } ); | |
| } ); | |