@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
23 lines (19 loc) • 569 B
JavaScript
/**
* Internal dependencies
*/
import replaceAction from '../replace-action';
describe( 'replaceAction', () => {
function createEnhancedReducer( replacer ) {
const enhanceReducer = replaceAction( replacer );
return enhanceReducer(
( state, action ) => 'Called by ' + action.after
);
}
it( 'should replace the action passed to the reducer', () => {
const reducer = createEnhancedReducer( ( action ) => ( {
after: action.before,
} ) );
const state = reducer( undefined, { before: 'foo' } );
expect( state ).toBe( 'Called by foo' );
} );
} );