/** * Internal dependencies */ import type { FetchHandler } from '../../types'; import httpV1Middleware from '../http-v1'; describe( 'HTTP v1 Middleware', () => { it( 'should use a POST for a PUT requests', () => { expect.hasAssertions(); const callback: FetchHandler = async ( options ) => { expect( options.method ).toBe( 'POST' ); expect( options.headers![ 'X-HTTP-Method-Override' ] ).toBe( 'PUT' ); }; httpV1Middleware( { method: 'PUT', data: {} }, callback ); } ); it( "shouldn't touch the options for GET requests", () => { expect.hasAssertions(); const requestOptions = { method: 'GET', path: '/wp/v2/posts' }; const callback: FetchHandler = async ( options ) => { expect( options ).toBe( requestOptions ); }; httpV1Middleware( requestOptions, callback ); } ); it( "shouldn't touch the options for an undefined method", () => { expect.hasAssertions(); const requestOptions = { path: '/wp/v2/posts' }; const callback: FetchHandler = async ( options ) => { expect( options ).toBe( requestOptions ); }; httpV1Middleware( requestOptions, callback ); } ); } );