Download wp-calypso/client/state/action-watchers/test/utils.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/action-watchers/test/utils.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/action-watchers/test/utils.js
-
curl -L -o utils.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/action-watchers/test/utils.js
812 Bytes
| import { mergeHandlers } from '../utils'; | |
| describe( '#mergeHandlers', () => { | |
| const inc = ( a ) => a + 1; | |
| const triple = ( a ) => a * 3; | |
| const action = 'DO_MATH'; | |
| const first = { [ action ]: [ inc ] }; | |
| const second = { [ action ]: [ triple ] }; | |
| test( 'should pass through a single handler', () => { | |
| expect( mergeHandlers( first ) ).toEqual( first ); | |
| } ); | |
| test( 'should combine lists of handlers for different action types', () => { | |
| const merged = mergeHandlers( { INCREMENT: [ inc ] }, { TRIPLE: [ triple ] } ); | |
| expect( merged ).toEqual( { | |
| INCREMENT: [ inc ], | |
| TRIPLE: [ triple ], | |
| } ); | |
| } ); | |
| test( 'should combine lists of handlers for the same action type', () => { | |
| const merged = mergeHandlers( first, second ); | |
| expect( merged[ action ] ).toEqual( [ inc, triple ] ); | |
| } ); | |
| } ); | |