Skip to content
Merged
Prev Previous commit
Add JSDoc and remove not needed check
  • Loading branch information
mmtr committed Dec 19, 2018
commit a5bbeecb3b4273e1a033a81f7a0d7eca525a2d07
6 changes: 6 additions & 0 deletions packages/api-fetch/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ const defaultFetchHandler = ( nextOptions ) => {

let fetchHandler = defaultFetchHandler;

/**
* Defines a custom fetch handler for making the requests that will override
* the default one using window.fetch
*
* @param {Function} newFetchHandler The new fetch handler
*/
function setFetchHandler( newFetchHandler ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this file was already lacking so JSDocs, but maybe a good time to start adding those.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in e2dc3d3

fetchHandler = newFetchHandler;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/api-fetch/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,12 @@ describe( 'apiFetch', () => {
// options object. It also assumes that some built-in middleware would
// either mutate or clone the original options if the extra middleware
// had been pushed to the stack.
expect.assertions( 2 );
expect.assertions( 1 );

const expectedOptions = {};

apiFetch.use( ( actualOptions, next ) => {
expect( actualOptions ).toBe( expectedOptions );
expect( actualOptions ).toEqual( expectedOptions );

return next( actualOptions );
} );
Expand Down