-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Fetch: Improve isMediaUploadRequest check
- Loading branch information
Showing
2 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import mediaUploadMiddleware from '../media-upload'; | ||
|
||
describe( 'Media Upload Middleware', () => { | ||
it( 'should defer to the next middleware with the same options', () => { | ||
expect.hasAssertions(); | ||
|
||
const originalOptions = { path: '/wp/v2/media' }; | ||
const next = ( options ) => { | ||
expect( options ).toBe( originalOptions ); | ||
}; | ||
|
||
mediaUploadMiddleware( originalOptions, next ); | ||
} ); | ||
|
||
it( 'should change options not to parse', () => { | ||
expect.hasAssertions(); | ||
|
||
const requestOptions = { method: 'POST', path: '/wp/v2/media' }; | ||
const next = ( options ) => { | ||
expect( options.parse ).toBe( false ); | ||
|
||
return Promise.resolve( { | ||
status: 200, | ||
json() { | ||
return Promise.resolve( [ 'item' ] ); | ||
}, | ||
} ); | ||
}; | ||
|
||
mediaUploadMiddleware( requestOptions, next ); | ||
} ); | ||
} ); |