UNPKG

@wordpress/api-fetch

Version:
26 lines (22 loc) 639 B
/** * Internal dependencies */ import type { FetchHandler } from '../../types'; import createRootUrlMiddleware from '../root-url'; describe( 'Root URL middleware', () => { it( 'should append the root URL', () => { expect.hasAssertions(); const rootURL = 'http://wp.org/wp-admin/rest/'; const rootURLMiddleware = createRootUrlMiddleware( rootURL ); const requestOptions = { method: 'GET', path: '/wp/v2/posts', }; const callback: FetchHandler = async ( options ) => { expect( options.url ).toBe( 'http://wp.org/wp-admin/rest/wp/v2/posts' ); }; rootURLMiddleware( requestOptions, callback ); } ); } );